@feathersjs/commons
Advanced tools
Comparing version 1.3.1 to 1.4.0
# Change Log | ||
## [v1.3.1](https://github.com/feathersjs/commons/tree/v1.3.1) (2018-01-12) | ||
[Full Changelog](https://github.com/feathersjs/commons/compare/v1.3.0...v1.3.1) | ||
**Merged pull requests:** | ||
- Allow array for sorting [\#66](https://github.com/feathersjs/commons/pull/66) ([daffl](https://github.com/daffl)) | ||
- Update semistandard to the latest version 🚀 [\#64](https://github.com/feathersjs/commons/pull/64) ([greenkeeper[bot]](https://github.com/apps/greenkeeper)) | ||
## [v1.3.0](https://github.com/feathersjs/commons/tree/v1.3.0) (2017-11-20) | ||
@@ -158,3 +166,3 @@ [Full Changelog](https://github.com/feathersjs/commons/compare/v1.2.0...v1.3.0) | ||
- Use forEach instead of ES6 'for of' loop [\#25](https://github.com/feathersjs/commons/pull/25) ([mrpatiwi](https://github.com/mrpatiwi)) | ||
- Use forEach instead of ES6 'for of' loop [\#25](https://github.com/feathersjs/commons/pull/25) ([lopezjurip](https://github.com/lopezjurip)) | ||
- mocha@2.5.0 breaks build 🚨 [\#24](https://github.com/feathersjs/commons/pull/24) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) | ||
@@ -161,0 +169,0 @@ - Update babel-plugin-add-module-exports to version 0.2.0 🚀 [\#23](https://github.com/feathersjs/commons/pull/23) ([greenkeeperio-bot](https://github.com/greenkeeperio-bot)) |
@@ -15,2 +15,5 @@ const { each, pick } = require('./utils')._; | ||
// To skip further hooks | ||
const SKIP = exports.SKIP = typeof Symbol !== 'undefined' ? Symbol('__feathersSkipHooks') : '__feathersSkipHooks'; | ||
// Converters from service method arguments to hook object properties | ||
@@ -145,2 +148,6 @@ exports.converters = { | ||
if (current) { | ||
if (current === SKIP) { | ||
return SKIP; | ||
} | ||
if (!exports.isHookObject(current)) { | ||
@@ -163,11 +170,9 @@ throw new Error(`${hookObject.type} hook for '${hookObject.method}' method returned invalid hook object`); | ||
if (hook.length === 2) { // function(hook, next) | ||
promise = promise.then(hookObject => { | ||
return new Promise((resolve, reject) => { | ||
hook(hookObject, (error, result) => | ||
error ? reject(error) : resolve(result) | ||
); | ||
}); | ||
}); | ||
promise = promise.then(hookObject => hookObject === SKIP ? SKIP : new Promise((resolve, reject) => { | ||
hook(hookObject, (error, result) => | ||
error ? reject(error) : resolve(result) | ||
); | ||
})); | ||
} else { // function(hook) | ||
promise = promise.then(hook); | ||
promise = promise.then(hookObject => hookObject === SKIP ? SKIP : hook(hookObject)); | ||
} | ||
@@ -179,7 +184,9 @@ | ||
return promise.catch(error => { | ||
// Add the hook information to any errors | ||
error.hook = hookObject; | ||
throw error; | ||
}); | ||
return promise | ||
.then(() => hookObject) | ||
.catch(error => { | ||
// Add the hook information to any errors | ||
error.hook = hookObject; | ||
throw error; | ||
}); | ||
}; | ||
@@ -186,0 +193,0 @@ |
{ | ||
"name": "@feathersjs/commons", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "Shared Feathers utility functions", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/feathersjs/commons", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38186
578