Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade packages to latest version #74

Merged
merged 9 commits into from
Jan 2, 2021
Merged
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: node_js
node_js:
- node
- 12
- 10
- 8
before_script:
- yarn build
script:
- yarn test:coverage
- yarn test
- yarn codecov
22 changes: 3 additions & 19 deletions examples/express-http-server-ts/backpack.config.js
Original file line number Diff line number Diff line change
@@ -2,10 +2,9 @@ const path = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
webpack: config => {
config.context = path.resolve(__dirname, 'src');
webpack: (config) => {
config.entry = {
main: './index.ts'
main: './src/index.ts'
};
config.output.path = path.resolve(__dirname, 'dist');
config.resolve.extensions = ['.ts', '.json'];
@@ -28,22 +27,7 @@ module.exports = {
}
];

// Setup polling on MacOS for hot-reloads
if (process.env.OS === 'darwin') {
config.watch = true;

config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
ignored: /node_modules/
};
}

config.plugins.push(
new ForkTsCheckerWebpackPlugin({
tsconfig: path.resolve(__dirname, 'tsconfig.json')
})
);
config.plugins.push(new ForkTsCheckerWebpackPlugin({}));

return config;
}
14 changes: 7 additions & 7 deletions examples/express-http-server-ts/package.json
Original file line number Diff line number Diff line change
@@ -9,18 +9,18 @@
"build": "backpack build"
},
"dependencies": {
"@leapfrogtechnology/async-store": "^1.1.0",
"@leapfrogtechnology/async-store": "^1.2.0",
"express": "^4.17.1"
},
"devDependencies": {
"@types/express": "^4.17.1",
"@types/node": "^12.7.8",
"@types/express": "^4.17.9",
"@types/node": "^14.14.17",
"backpack-core": "^0.8.4",
"fork-ts-checker-webpack-plugin": "^1.5.0",
"ts-loader": "^6.1.2",
"tslint": "^5.20.0",
"fork-ts-checker-webpack-plugin": "^6.0.8",
"ts-loader": "^8.0.13",
"tslint": "^6.1.3",
"tslint-config-leapfrog": "^1.0.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.7.2"
"typescript": "^4.1.3"
}
}
2 changes: 1 addition & 1 deletion examples/express-http-server-ts/src/service.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ export function doSomethingAsync() {
setTimeout(() => {
const data = store.getAll();
logger.info('Store contents: ' + JSON.stringify(data));
resolve();
resolve(null);
}, 2000);
});
}
3,119 changes: 1,701 additions & 1,418 deletions examples/express-http-server-ts/yarn.lock

Large diffs are not rendered by default.

22 changes: 3 additions & 19 deletions examples/koa-http-server-ts/backpack.config.js
Original file line number Diff line number Diff line change
@@ -2,10 +2,9 @@ const path = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
webpack: config => {
config.context = path.resolve(__dirname, 'src');
webpack: (config) => {
config.entry = {
main: './index.ts'
main: './src/index.ts'
};
config.output.path = path.resolve(__dirname, 'dist');
config.resolve.extensions = ['.ts', '.json'];
@@ -28,22 +27,7 @@ module.exports = {
}
];

// Setup polling on MacOS for hot-reloads
if (process.env.OS === 'darwin') {
config.watch = true;

config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
ignored: /node_modules/
};
}

config.plugins.push(
new ForkTsCheckerWebpackPlugin({
tsconfig: path.resolve(__dirname, 'tsconfig.json')
})
);
config.plugins.push(new ForkTsCheckerWebpackPlugin({}));

return config;
}
18 changes: 9 additions & 9 deletions examples/koa-http-server-ts/package.json
Original file line number Diff line number Diff line change
@@ -14,20 +14,20 @@
},
"dependencies": {
"@leapfrogtechnology/async-store": "^1.2.0",
"koa": "^2.11.0",
"koa": "^2.13.0",
"koa-request": "^1.0.0",
"qs": "^6.9.1"
"qs": "^6.9.4"
},
"devDependencies": {
"@types/koa": "^2.11.0",
"@types/node": "^12.12.14",
"@types/qs": "^6.9.0",
"@types/koa": "^2.11.6",
"@types/node": "^14.14.17",
"@types/qs": "^6.9.5",
"backpack-core": "^0.8.4",
"fork-ts-checker-webpack-plugin": "^3.1.1",
"ts-loader": "^6.2.1",
"tslint": "^5.20.1",
"fork-ts-checker-webpack-plugin": "^6.0.8",
"ts-loader": "^8.0.13",
"tslint": "^6.1.3",
"tslint-config-leapfrog": "^1.0.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.7.2"
"typescript": "^4.1.3"
}
}
2 changes: 1 addition & 1 deletion examples/koa-http-server-ts/src/service.ts
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ export function doSomethingAsync(): Promise<void> {
// Do something with the request with a delay.
logger.debug('Simulating delayed access');

return new Promise(resolve => {
return new Promise((resolve) => {
setTimeout(() => {
const data = store.getAll();
logger.info('Store contents: ' + JSON.stringify(data));
3,114 changes: 1,694 additions & 1,420 deletions examples/koa-http-server-ts/yarn.lock

Large diffs are not rendered by default.

22 changes: 3 additions & 19 deletions examples/micro-http-server-ts/backpack.config.js
Original file line number Diff line number Diff line change
@@ -2,10 +2,9 @@ const path = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
webpack: config => {
config.context = path.resolve(__dirname, 'src');
webpack: (config) => {
config.entry = {
main: './index.ts'
main: './src/index.ts'
};
config.output.path = path.resolve(__dirname, 'dist');
config.resolve.extensions = ['.ts', '.json'];
@@ -28,22 +27,7 @@ module.exports = {
}
];

// Setup polling on MacOS for hot-reloads
if (process.env.OS === 'darwin') {
config.watch = true;

config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
ignored: /node_modules/
};
}

config.plugins.push(
new ForkTsCheckerWebpackPlugin({
tsconfig: path.resolve(__dirname, 'tsconfig.json')
})
);
config.plugins.push(new ForkTsCheckerWebpackPlugin({}));

return config;
}
16 changes: 8 additions & 8 deletions examples/micro-http-server-ts/package.json
Original file line number Diff line number Diff line change
@@ -10,18 +10,18 @@
"author": "",
"license": "ISC",
"dependencies": {
"@leapfrogtechnology/async-store": "^1.1.0",
"micro": "^9.3.4",
"qs": "^6.9.1"
"@leapfrogtechnology/async-store": "^1.2.0",
"micro": "^9.3.5-canary.3",
"qs": "^6.9.4"
},
"devDependencies": {
"@types/qs": "^6.5.3",
"@types/qs": "^6.9.5",
"backpack-core": "^0.8.4",
"fork-ts-checker-webpack-plugin": "^1.5.0",
"ts-loader": "^6.1.2",
"tslint": "^5.20.0",
"fork-ts-checker-webpack-plugin": "^6.0.8",
"ts-loader": "^8.0.13",
"tslint": "^6.1.3",
"tslint-config-leapfrog": "^1.0.3",
"tslint-config-prettier": "^1.18.0",
"typescript": "^3.7.2"
"typescript": "^4.1.3"
}
}
19 changes: 11 additions & 8 deletions examples/micro-http-server-ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as micro from 'micro';
import * as http from 'http';
import micro from 'micro';
import { IncomingMessage, ServerResponse } from 'http';

import * as store from '@leapfrogtechnology/async-store';
@@ -8,13 +9,15 @@ import { storeParams, calculateSum } from './middlewares';

const PORT = 3000;

const server = micro((req: IncomingMessage, res: ServerResponse) => {
store.initialize()(() => {
storeParams((req.url || '').split('?', 2)[1]);
calculateSum(req, res);
handleRequest(req, res);
});
});
const server = new http.Server(
micro((req: IncomingMessage, res: ServerResponse) => {
store.initialize()(() => {
storeParams((req.url || '').split('?', 2)[1]);
calculateSum(req, res);
handleRequest(req, res);
});
})
);

server.listen(PORT, () => {
logger.info(`HTTP server listening on port ${PORT}!\n`);
2 changes: 1 addition & 1 deletion examples/micro-http-server-ts/src/service.ts
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ export function doSomethingAsync() {
setTimeout(() => {
const data = store.getAll();
logger.info('Store contents: ' + JSON.stringify(data));
resolve();
resolve(null);
}, 2000);
});
}
3,044 changes: 1,675 additions & 1,369 deletions examples/micro-http-server-ts/yarn.lock

Large diffs are not rendered by default.

22 changes: 3 additions & 19 deletions examples/node-http-server-ts/backpack.config.js
Original file line number Diff line number Diff line change
@@ -2,10 +2,9 @@ const path = require('path');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = {
webpack: config => {
config.context = path.resolve(__dirname, 'src');
webpack: (config) => {
config.entry = {
main: './index.ts'
main: './src/index.ts'
};
config.output.path = path.resolve(__dirname, 'dist');
config.resolve.extensions = ['.ts', '.json'];
@@ -28,22 +27,7 @@ module.exports = {
}
];

// Setup polling on MacOS for hot-reloads
if (process.env.OS === 'darwin') {
config.watch = true;

config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
ignored: /node_modules/
};
}

config.plugins.push(
new ForkTsCheckerWebpackPlugin({
tsconfig: path.resolve(__dirname, 'tsconfig.json')
})
);
config.plugins.push(new ForkTsCheckerWebpackPlugin({}));

return config;
}
2 changes: 1 addition & 1 deletion examples/node-http-server-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "async-store-example-node-ts",
"version": "1.0.0",
"description": "A basic example for async-store and node and typescript.",
"description": "A basic example for async-store and node and TypeScript.",
"main": "index.js",
"scripts": {
"start": "backpack",
2 changes: 1 addition & 1 deletion examples/node-http-server-ts/src/service.ts
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ export function doSomethingAsync() {
setTimeout(() => {
const data = store.getAll();
logger.info('Store contents: ' + JSON.stringify(data));
resolve();
resolve(null);
}, 2000);
});
}
2,963 changes: 1,631 additions & 1,332 deletions examples/node-http-server-ts/yarn.lock

Large diffs are not rendered by default.

51 changes: 24 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -22,11 +22,9 @@
"clean": "rimraf dist",
"codecov": "codecov",
"build": "NODE_ENV=production yarn clean && yarn transpile",
"test": "NODE_ENV=test mocha --recursive test/**/*.test.ts",
"test:watch": "NODE_ENV=test mocha --watch --recursive test/**/*.test.ts",
"test:coverage": "NODE_ENV=test nyc mocha --recursive test/**/*.test.ts",
"test": "NODE_ENV=test nyc mocha --recursive test/**/*.test.ts",
"watch": "tsc --watch",
"prettify": "prettier --single-quote --parser typescript --print-width 120 --write './**/*.{ts,js}'",
"prettify": "prettier --single-quote --trailing-comma none --print-width 120 --write './**/*.{ts,js,yml}'",
"prepublishOnly": "yarn build",
"changelog": "./release.sh changelog",
"release": "./release.sh bump"
@@ -38,10 +36,9 @@
}
},
"lint-staged": {
"*.{ts,js}": [
"*.{ts,js,yml}": [
"tslint --fix -c tslint.json",
"prettier --single-quote --parser typescript --print-width 120 --write './**/*.{ts,js}'",
"git add"
"prettier --single-quote --trailing-comma none --print-width 120 --write './**/*.{ts,js,yml}'"
]
},
"keywords": [
@@ -62,34 +59,34 @@
"Sagar Chamling <sagarchamling@lftechnology.com>"
],
"dependencies": {
"debug": "4.1.1",
"ramda": "0.26.1",
"uuid": "3.3.2"
"debug": "4.3.1",
"ramda": "0.27.1",
"uuid": "8.3.2"
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^0.1.3",
"@types/chai": "^4.2.3",
"@types/chai-as-promised": "^7.1.2",
"@istanbuljs/nyc-config-typescript": "^1.0.1",
"@types/chai": "^4.2.14",
"@types/chai-as-promised": "^7.1.3",
"@types/debug": "^4.1.5",
"@types/express": "^4.17.1",
"@types/mocha": "^5.2.7",
"@types/ramda": "^0.26.25",
"@types/uuid": "^3.4.5",
"@types/express": "^4.17.9",
"@types/mocha": "^8.2.0",
"@types/ramda": "^0.27.34",
"@types/uuid": "^8.3.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"codecov": "^3.6.1",
"husky": "^3.0.7",
"lint-staged": "^9.4.0",
"mocha": "^6.2.0",
"node-mocks-http": "^1.8.0",
"nyc": "^14.1.1",
"prettier": "^1.18.2",
"ts-node": "^8.4.1",
"tslint": "^5.20.0",
"codecov": "^3.8.1",
"husky": "^4.3.6",
"lint-staged": "^10.5.3",
"mocha": "^8.2.1",
"node-mocks-http": "^1.9.0",
"nyc": "^15.1.0",
"prettier": "^2.2.1",
"ts-node": "^9.1.1",
"tslint": "^6.1.3",
"tslint-config-leapfrog": "^1.0.3",
"tslint-config-prettier": "^1.18.0",
"tslint-no-unused-expression-chai": "^0.1.4",
"typescript": "^3.6.3"
"typescript": "^4.1.3"
},
"publishConfig": {
"access": "public"
4 changes: 2 additions & 2 deletions src/impl/domain.ts
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ function bindParams(d: StoreDomainInterface, params: AsyncStoreParams): void {

logDomain(`Binding emitters.`);
if (emitters && Array.isArray(emitters)) {
emitters.forEach(emitter => d.add(emitter));
emitters.forEach((emitter) => d.add(emitter));
}

if (error) {
@@ -156,7 +156,7 @@ export function getByKeys<T>(keys: string[]): T[] {
throw new Error('No keys provided for getting the values from store.');
}

return keys.map(key => get(key));
return keys.map((key) => get(key));
}

/**
85 changes: 38 additions & 47 deletions test/domain.test.ts
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ describe('store: [adapter=DOMAIN]', () => {
});

describe('initialize()', () => {
it('should initialize the store.', done => {
it('should initialize the store.', (done) => {
const callback = () => {
expect(!!(process.domain as any)[STORE_KEY]).to.equal(true);
expect(globalStore.isInitialized()).to.equal(true);
@@ -39,7 +39,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should also bind params if params are passed through arguments.', done => {
it('should also bind params if params are passed through arguments.', (done) => {
const req = new EventEmitter();
const res = new EventEmitter();
const emitters = [req, res];
@@ -84,11 +84,11 @@ describe('store: [adapter=DOMAIN]', () => {
expect(globalStore.isInitialized()).to.equal(false);
});

it('should return true when initialized through the middleware.', done => {
it('should return true when initialized through the middleware.', (done) => {
checkStore(done);
});

it('should return false when initialized but invoked out of the active domain.', done => {
it('should return false when initialized but invoked out of the active domain.', (done) => {
// Initialized
globalStore.initialize(adapter)(() => null);

@@ -99,7 +99,7 @@ describe('store: [adapter=DOMAIN]', () => {
}, 500);
});

it('should return true when initialized and invoked within the active domain.', done => {
it('should return true when initialized and invoked within the active domain.', (done) => {
const callback = () => {
expect(globalStore.isInitialized()).to.equal(true);
done();
@@ -114,7 +114,7 @@ describe('store: [adapter=DOMAIN]', () => {
expect(globalStore.get.bind(globalStore, 'foo')).to.throw('No active domain found in store.');
});

it('should return null if invoked under active domain w/o proper store initialization.', done => {
it('should return null if invoked under active domain w/o proper store initialization.', (done) => {
const d = domain.create();

d.run(() => {
@@ -125,7 +125,7 @@ describe('store: [adapter=DOMAIN]', () => {
});
});

it('should return `undefined` if the value was not set.', done => {
it('should return `undefined` if the value was not set.', (done) => {
const callback = () => {
expect(globalStore.get('foo')).to.equal(undefined);
done();
@@ -136,7 +136,7 @@ describe('store: [adapter=DOMAIN]', () => {
});

describe('getAll()', () => {
it('should return all values from the store.', done => {
it('should return all values from the store.', (done) => {
const a = 1;
const b = 2;
const sum = a + b;
@@ -162,7 +162,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should return null if invoked under active domain w/o proper store initialization.', done => {
it('should return null if invoked under active domain w/o proper store initialization.', (done) => {
const d = domain.create();

d.run(() => {
@@ -179,7 +179,7 @@ describe('store: [adapter=DOMAIN]', () => {
expect(globalStore.get.bind(globalStore, 'foo')).to.throw('No active domain found in store.');
});

it('should return `undefined` as the value for requested keys that were not set.', done => {
it('should return `undefined` as the value for requested keys that were not set.', (done) => {
const callback = () => {
expect(globalStore.getByKeys(['foo', 'bar'])).to.deep.equal([undefined, undefined]);

@@ -189,7 +189,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should return an array of matching values in the same order as the list of requested keys.', done => {
it('should return an array of matching values in the same order as the list of requested keys.', (done) => {
const callback = () => {
globalStore.set({ a: 1, b: 2, sum: 3, somethingNull: null });

@@ -201,7 +201,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should return an identical array of same length even if there are unknown (not set) keys.', done => {
it('should return an identical array of same length even if there are unknown (not set) keys.', (done) => {
const callback = () => {
globalStore.set({ a: 1, b: 2, z: 5 });

@@ -225,7 +225,7 @@ describe('store: [adapter=DOMAIN]', () => {
});

describe('getId()', () => {
it('should return unique value if store is initialized.', done => {
it('should return unique value if store is initialized.', (done) => {
const callback = () => {
expect(globalStore.getId()).to.be.an('string');
expect(globalStore.getId()).to.not.equal(null);
@@ -237,7 +237,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should return `undefined` if store is not initialized.', done => {
it('should return `undefined` if store is not initialized.', (done) => {
expect(globalStore.getId).to.not.throw();
expect(globalStore.getId()).to.equal(undefined);

@@ -246,7 +246,7 @@ describe('store: [adapter=DOMAIN]', () => {
});

describe('getShortId()', () => {
it('should return short (8 chars) unique value if store is initialized.', done => {
it('should return short (8 chars) unique value if store is initialized.', (done) => {
const callback = () => {
expect(globalStore.getShortId()).to.be.an('string');
expect(globalStore.getShortId()).to.not.equal(null);
@@ -259,7 +259,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should return `undefined` if store is not initialized.', done => {
it('should return `undefined` if store is not initialized.', (done) => {
expect(globalStore.getShortId).to.not.throw();
expect(globalStore.getShortId()).to.equal(undefined);

@@ -268,7 +268,7 @@ describe('store: [adapter=DOMAIN]', () => {
});

describe('find()', () => {
it('should successfully return value in synchronous callback.', done => {
it('should successfully return value in synchronous callback.', (done) => {
const callback = () => {
first();
second();
@@ -306,7 +306,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should successfully return value in asynchronous callback.', done => {
it('should successfully return value in asynchronous callback.', (done) => {
const callback = () => {
globalStore.set({ foo: 'bar' });

@@ -338,7 +338,7 @@ describe('store: [adapter=DOMAIN]', () => {
expect(globalStore.find('foo')).to.equal(null);
});

it('should return `undefined` if the value was not set.', done => {
it('should return `undefined` if the value was not set.', (done) => {
const callback = () => {
expect(globalStore.find('foo')).to.equal(undefined);
done();
@@ -353,7 +353,7 @@ describe('store: [adapter=DOMAIN]', () => {
expect(globalStore.set.bind(globalStore, {})).to.throw('Async store not initialized.');
});

it('should throw an error if invalid arguments are provided.', done => {
it('should throw an error if invalid arguments are provided.', (done) => {
const callback = () => {
expect(globalStore.set.bind(globalStore, 5)).to.throw('Invalid arguments provided for asyncStore.set()');
expect(globalStore.set.bind(globalStore, 'five')).to.throw('Invalid arguments provided for asyncStore.set()');
@@ -368,7 +368,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should set properties in the store.', done => {
it('should set properties in the store.', (done) => {
const callback = () => {
globalStore.set({ foo: 'Hello', bar: 'World' });
second();
@@ -383,7 +383,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should merge and override existing properties if set multiple times.', done => {
it('should merge and override existing properties if set multiple times.', (done) => {
const callback = () => {
globalStore.set({ foo: 'Hello', bar: 'World' });
second();
@@ -407,7 +407,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should merge and override existing properties recursively.', done => {
it('should merge and override existing properties recursively.', (done) => {
const callback = () => {
first();
second();
@@ -454,7 +454,7 @@ describe('store: [adapter=DOMAIN]', () => {
});

describe('Test Cases:', () => {
it('should work with a chain of sequentially invoked callbacks (synchronous).', done => {
it('should work with a chain of sequentially invoked callbacks (synchronous).', (done) => {
const callback = () => {
globalStore.set({ foo: 'foo', bar: 'bar' });

@@ -483,7 +483,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should work with chain of promises resolved.', done => {
it('should work with chain of promises resolved.', (done) => {
const doSomething = () =>
Promise.resolve()
.then(() => {
@@ -511,7 +511,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should work with chain of promises (resolved or rejected).', done => {
it('should work with chain of promises (resolved or rejected).', (done) => {
const doSomething = () =>
Promise.reject()
.then(() => {
@@ -524,15 +524,13 @@ describe('store: [adapter=DOMAIN]', () => {
const callback = () => {
globalStore.set({ bar: 'Bar' });

doSomething()
.then(done)
.catch(done);
doSomething().then(done).catch(done);
};

globalStore.initialize(adapter)(callback);
});

it('should work with Promise.all().', done => {
it('should work with Promise.all().', (done) => {
const p1 = () =>
Promise.resolve().then(() => {
expect(globalStore.get('baz')).to.equal('Baz');
@@ -555,15 +553,13 @@ describe('store: [adapter=DOMAIN]', () => {
const callback = () => {
globalStore.set({ baz: 'Baz' });

doSomething()
.then(done)
.catch(done);
doSomething().then(done).catch(done);
};

globalStore.initialize(adapter)(callback);
});

it('should work with setTimeout() based async callback chains.', done => {
it('should work with setTimeout() based async callback chains.', (done) => {
const callback = () => {
setTimeout(() => {
globalStore.set({ foo: 'foo' });
@@ -611,7 +607,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should work with setImmediate() based async callback chains.', done => {
it('should work with setImmediate() based async callback chains.', (done) => {
const callback = () => {
setImmediate(() => {
globalStore.set({ foo: 'foo' });
@@ -651,7 +647,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should work with process.nextTick() based async callback chains.', done => {
it('should work with process.nextTick() based async callback chains.', (done) => {
const callback = () => {
process.nextTick(() => {
globalStore.set({ foo: 'foo' });
@@ -691,14 +687,14 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should work with async and await based callbacks.', done => {
it('should work with async and await based callbacks.', (done) => {
const p1 = () => {
return new Promise(resolve => {
return new Promise((resolve) => {
expect(globalStore.get('foo')).to.equal('foo');

setTimeout(() => {
expect(globalStore.get('foo')).to.equal('foo');
resolve();
resolve(null);
}, 1);
});
};
@@ -724,7 +720,7 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it('should work with stores in different callback contexts loaded separately (dynamic import()).', done => {
it('should work with stores in different callback contexts loaded separately (dynamic import()).', (done) => {
const first = async () => {
const store = await import('../src');

@@ -776,19 +772,14 @@ describe('store: [adapter=DOMAIN]', () => {
globalStore.initialize(adapter)(callback);
});

it("should work even if the store is initialized under active domain w/o affecting the existing domain's attributes.", done => {
it("should work even if the store is initialized under active domain w/o affecting the existing domain's attributes.", (done) => {
// Existing domain.
const d = domain.create() as any;

d.existingData = 'Hello world';

const callback = () => {
Promise.resolve()
.then(first)
.then(second)
.then(third)
.then(done)
.catch(done);
Promise.resolve().then(first).then(second).then(third).then(done).catch(done);
};

const first = () => {
2,750 changes: 1,181 additions & 1,569 deletions yarn.lock

Large diffs are not rendered by default.