Skip to content

Commit

Permalink
fix: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Jul 28, 2019
1 parent aee852a commit 57fe7b0
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 112 deletions.
45 changes: 27 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,45 @@
"url": "http://gajus.com"
},
"ava": {
"files": [
"test/**/*"
],
"helpers": [
"test/helpers/**/*"
],
"require": [
"@babel/register"
],
"sources": [
"src/**/*"
]
},
"dependencies": {
"boolean": "^0.2.0",
"boolean": "^1.0.0",
"json-stringify-safe": "^5.0.1",
"semver-compare": "^1.0.0",
"sprintf-js": "^1.1.2"
},
"description": "JSON logger for Node.js and browser.",
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.2.2",
"@babel/node": "^7.2.2",
"@babel/plugin-transform-flow-strip-types": "^7.2.3",
"@babel/preset-env": "^7.3.1",
"@babel/register": "^7.0.0",
"ava": "^1.2.1",
"babel-plugin-istanbul": "^5.1.0",
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/node": "^7.5.5",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/preset-env": "^7.5.5",
"@babel/register": "^7.5.5",
"ava": "^2.2.0",
"babel-plugin-istanbul": "^5.2.0",
"babel-plugin-transform-export-default-name": "^2.0.4",
"coveralls": "^3.0.2",
"eslint": "^5.13.0",
"eslint-config-canonical": "^16.1.0",
"flow-bin": "^0.92.1",
"flow-copy-source": "^2.0.2",
"gitdown": "^2.5.7",
"husky": "^1.3.1",
"nyc": "^13.2.0",
"semantic-release": "^15.13.3"
"coveralls": "^3.0.5",
"eslint": "^6.1.0",
"eslint-config-canonical": "^17.3.2",
"flow-bin": "^0.104.0",
"flow-copy-source": "^2.0.7",
"gitdown": "^3.1.1",
"husky": "^3.0.1",
"nyc": "^14.1.1",
"semantic-release": "^15.13.18"
},
"engines": {
"node": ">=6.0"
Expand Down
2 changes: 1 addition & 1 deletion src/benchmark/roarr.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ global.ROARR = createRoarrInititialGlobalState({});

const Writer = createWriter({
bufferSize: 1024 * 8,
stream: 'STDOUT'
stream: 'STDOUT',
});

for (let i = 0; i < 1 * 1000 * 1000; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ if (isNaN(ROARR_BUFFER_SIZE)) {
export {
ROARR_BUFFER_SIZE,
ROARR_LOG,
ROARR_STREAM
ROARR_STREAM,
};
24 changes: 12 additions & 12 deletions src/factories/createLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import stringify from 'json-stringify-safe';
import {
sprintf
sprintf,
} from 'sprintf-js';
import type {
LoggerType,
MessageContextType,
MessageType,
TranslateMessageFunctionType
TranslateMessageFunctionType,
} from '../types';
import {
ROARR_LOG
ROARR_LOG,
} from '../config';

type OnMessageEventHandlerType = (message: MessageType) => void;
Expand All @@ -24,11 +24,11 @@ const logLevels = {
fatal: 60,
info: 30,
trace: 10,
warn: 40
warn: 40,
};

const createLogger = (onMessage: OnMessageEventHandlerType, parentContext?: MessageContextType): LoggerType => {
// eslint-disable-next-line id-length
// eslint-disable-next-line id-length, unicorn/prevent-abbreviations
const log = (a, b, c, d, e, f, g, h, i, k) => {
if (!ROARR_LOG && !global.ROARR_LOG) {
return;
Expand All @@ -42,7 +42,7 @@ const createLogger = (onMessage: OnMessageEventHandlerType, parentContext?: Mess

if (typeof a === 'string') {
context = {
...parentContext || {}
...parentContext || {},
};
message = sprintf(a, b, c, d, e, f, g, h, i, k);
} else {
Expand All @@ -52,7 +52,7 @@ const createLogger = (onMessage: OnMessageEventHandlerType, parentContext?: Mess

context = JSON.parse(stringify({
...parentContext || {},
...a
...a,
}));

message = sprintf(b, c, d, e, f, g, h, i, k);
Expand All @@ -63,7 +63,7 @@ const createLogger = (onMessage: OnMessageEventHandlerType, parentContext?: Mess
message,
sequence,
time,
version
version,
});
};

Expand All @@ -79,21 +79,21 @@ const createLogger = (onMessage: OnMessageEventHandlerType, parentContext?: Mess

return createLogger(onMessage, {
...parentContext,
...context
...context,
});
};

log.getContext = (): MessageContextType => {
return {
...parentContext || {}
...parentContext || {},
};
};

for (const logLevel of Object.keys(logLevels)) {
// eslint-disable-next-line id-length
// eslint-disable-next-line id-length, unicorn/prevent-abbreviations
log[logLevel] = (a, b, c, d, e, f, g, h, i, k) => {
return log.child({
logLevel: logLevels[logLevel]
logLevel: logLevels[logLevel],
})(a, b, c, d, e, f, g, h, i, k);
};
}
Expand Down
12 changes: 6 additions & 6 deletions src/factories/createRoarrInititialGlobalState.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import cmp from 'semver-compare';
import {
version
version,
} from '../../package.json';
import type {
RoarrGlobalStateType
RoarrGlobalStateType,
} from '../types';
import {
ROARR_BUFFER_SIZE,
ROARR_STREAM
ROARR_STREAM,
} from '../config';
import createWriter from './createWriter';

Expand All @@ -32,16 +32,16 @@ export default (currentState: Object): RoarrGlobalStateType => {
prepend: {},
sequence: 0,
...currentState,
versions
versions,
};

if (currentIsLatestVersion || !newState.write) {
newState = {
...newState,
...createWriter({
bufferSize: ROARR_BUFFER_SIZE,
stream: ROARR_STREAM
})
stream: ROARR_STREAM,
}),
};
}

Expand Down
8 changes: 4 additions & 4 deletions src/factories/createWriter.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// @flow

import type {
WriterType
WriterType,
} from '../types';

type WriteConfigurationType = {|
+bufferSize: number,
+stream: 'STDOUT' | 'STDERR'
+stream: 'STDOUT' | 'STDERR',
|};

const createBlockingWriter = (stream: stream$Writable): WriterType => {
return {
flush: () => {},
write: (message: string) => {
stream.write(message + '\n');
}
},
};
};

Expand All @@ -41,7 +41,7 @@ const createBufferedWriter = (stream: stream$Writable, bufferSize: number): Writ
}

// @todo Write messages when the event loop is not busy.
}
},
};
};

Expand Down
4 changes: 2 additions & 2 deletions src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {
createLogger,
createRoarrInititialGlobalState
createRoarrInititialGlobalState,
} from './factories';

global.ROARR = createRoarrInititialGlobalState(global.ROARR || {});
Expand All @@ -22,7 +22,7 @@ if (!global.ROARR.registeredFlush) {
export type {
LoggerType,
MessageType,
TranslateMessageFunctionType
TranslateMessageFunctionType,
} from './types';

export default createLogger((message) => {
Expand Down
10 changes: 5 additions & 5 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
export type SerializableValueType = string | number | boolean | null | {+[key: string]: SerializableValueType} | $ReadOnlyArray<SerializableValueType>;

export type SerializableObjectType = {
+[key: string]: SerializableValueType
+[key: string]: SerializableValueType,
};

export type WriterType = {|
+flush: (message: string) => void,
+write: (message: string) => void
+write: (message: string) => void,
|};

export type RoarrGlobalStateType = {|
Expand All @@ -19,7 +19,7 @@ export type RoarrGlobalStateType = {|
registeredFlush: boolean,
sequence: number,
versions: $ReadOnlyArray<string>,
...WriterType
...WriterType,
|};

export type SprintfArgumentType = string | number | boolean | null;
Expand All @@ -32,7 +32,7 @@ export type MessageType = {|
+message: string,
+sequence: number,
+time: number,
+version: string
+version: string,
|};

export type TranslateMessageFunctionType = (message: MessageType) => MessageType;
Expand Down Expand Up @@ -77,5 +77,5 @@ export type LoggerType = {|
+getContext: () => MessageContextType,
+info: typeof Logger,
+trace: typeof Logger,
+warn: typeof Logger
+warn: typeof Logger,
|};
26 changes: 13 additions & 13 deletions test/roarr/createRoarrInititialGlobalState.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ test('creates new state', (t) => {
prepend: {},
sequence: 0,
versions: [
'1.0.0'
]
'1.0.0',
],
});
});

test('respects existing sequence', (t) => {
const state = createRoarrInititialGlobalState({
sequence: 1
sequence: 1,
});

delete state.flush;
Expand All @@ -34,16 +34,16 @@ test('respects existing sequence', (t) => {
prepend: {},
sequence: 1,
versions: [
'1.0.0'
]
'1.0.0',
],
});
});

test('appends the latest version', (t) => {
const state = createRoarrInititialGlobalState({
versions: [
'0.0.1'
]
'0.0.1',
],
});

delete state.flush;
Expand All @@ -55,8 +55,8 @@ test('appends the latest version', (t) => {
sequence: 0,
versions: [
'0.0.1',
'1.0.0'
]
'1.0.0',
],
});
});

Expand All @@ -69,9 +69,9 @@ test('sets "write" method if current is the first version', (t) => {
test('overrides "write" method if current is the latest version', (t) => {
const state = createRoarrInititialGlobalState({
versions: [
'0.0.1'
'0.0.1',
],
write: 'foo'
write: 'foo',
});

t.true(typeof state.write === 'function');
Expand All @@ -80,9 +80,9 @@ test('overrides "write" method if current is the latest version', (t) => {
test('does not override "write" method if current is not the latest version', (t) => {
const state = createRoarrInititialGlobalState({
versions: [
'2.0.0'
'2.0.0',
],
write: 'foo'
write: 'foo',
});

t.true(state.write === 'foo');
Expand Down
Loading

0 comments on commit 57fe7b0

Please sign in to comment.