xod-func-tools
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.tapP = exports.notEmpty = exports.notNil = exports.optionalObjOf = exports.isAmong = exports.omitEmptyValues = exports.omitNilValues = exports.foldEither = exports.explodeMaybe = exports.explode = undefined; | ||
exports.rejectWithCode = exports.tapP = exports.hasNo = exports.notEmpty = exports.notNil = exports.optionalObjOf = exports.isAmong = exports.omitEmptyValues = exports.omitNilValues = exports.explodeEither = exports.foldEither = exports.explodeMaybe = exports.explode = undefined; | ||
@@ -38,2 +38,6 @@ var _types = require('./types'); | ||
/** | ||
* DEPRECATED: Use of this function lead to meaningless error messages that | ||
* are nearly impossible to debug. Use `explodeMaybe` and `explodeEither` | ||
* to convert monads to unhandled exceptions. | ||
* | ||
* Function to rapidly extract a value from Maybe or Either monad. | ||
@@ -94,2 +98,10 @@ * But it should be used only when we're sure that we should have a value, | ||
/** | ||
* Unwraps Either monad and returns it’s value if it is Right and throws an Error | ||
* if it is Left. | ||
*/ | ||
var explodeEither = exports.explodeEither = def('explodeMaybe :: Either a b -> b', foldEither(function (err) { | ||
throw new Error('Explosion failed: ' + err); | ||
}, _ramda2.default.identity)); | ||
/** | ||
* Returns an object provided with all `null` and `undefined` values omitted | ||
@@ -121,2 +133,3 @@ */ | ||
var notEmpty = exports.notEmpty = _ramda2.default.complement(_ramda2.default.isEmpty); | ||
var hasNo = exports.hasNo = _ramda2.default.complement(_ramda2.default.has); | ||
@@ -134,2 +147,7 @@ /** | ||
// :: ERROR_CODE -> Error -> Promise.Reject Error | ||
var rejectWithCode = exports.rejectWithCode = _ramda2.default.curry(function (code, err) { | ||
return Promise.reject(Object.assign(err, { errorCode: code })); | ||
}); | ||
exports.default = Object.assign({ | ||
@@ -139,2 +157,3 @@ explode: explode, | ||
foldEither: foldEither, | ||
hasNo: hasNo, | ||
omitNilValues: omitNilValues, | ||
@@ -145,3 +164,5 @@ omitEmptyValues: omitEmptyValues, | ||
notNil: notNil, | ||
notEmpty: notEmpty | ||
}, types); | ||
notEmpty: notEmpty, | ||
rejectWithCode: rejectWithCode | ||
}, types); | ||
//# sourceMappingURL=index.js.map |
@@ -151,2 +151,3 @@ 'use strict'; | ||
env: env | ||
}); | ||
}); | ||
//# sourceMappingURL=types.js.map |
{ | ||
"name": "xod-func-tools", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "", | ||
@@ -11,8 +11,8 @@ "keywords": [], | ||
"doc": "documentation build --format html --output doc --sort-order alpha src/", | ||
"build": "babel src/ -d dist/", | ||
"dev": "npm run build -- --watch", | ||
"build": "babel src/ -d dist/ --source-maps", | ||
"dev": "yarn run build -- --watch", | ||
"test": "mocha test/**/*.spec.js" | ||
}, | ||
"dependencies": { | ||
"hm-def": "^0.1.2", | ||
"hm-def": "^0.2.0", | ||
"ramda": "^0.22.1", | ||
@@ -19,0 +19,0 @@ "ramda-fantasy": "^0.7.0", |
@@ -10,2 +10,6 @@ import R from 'ramda'; | ||
/** | ||
* DEPRECATED: Use of this function lead to meaningless error messages that | ||
* are nearly impossible to debug. Use `explodeMaybe` and `explodeEither` | ||
* to convert monads to unhandled exceptions. | ||
* | ||
* Function to rapidly extract a value from Maybe or Either monad. | ||
@@ -72,2 +76,14 @@ * But it should be used only when we're sure that we should have a value, | ||
/** | ||
* Unwraps Either monad and returns it’s value if it is Right and throws an Error | ||
* if it is Left. | ||
*/ | ||
export const explodeEither = def( | ||
'explodeMaybe :: Either a b -> b', | ||
foldEither( | ||
(err) => { throw new Error(`Explosion failed: ${err}`); }, | ||
R.identity | ||
) | ||
); | ||
/** | ||
* Returns an object provided with all `null` and `undefined` values omitted | ||
@@ -108,2 +124,3 @@ */ | ||
export const notEmpty = R.complement(R.isEmpty); | ||
export const hasNo = R.complement(R.has); | ||
@@ -117,2 +134,8 @@ /** | ||
// :: ERROR_CODE -> Error -> Promise.Reject Error | ||
export const rejectWithCode = R.curry( | ||
(code, err) => Promise.reject(Object.assign(err, { errorCode: code })) | ||
); | ||
export default Object.assign( | ||
@@ -123,2 +146,3 @@ { | ||
foldEither, | ||
hasNo, | ||
omitNilValues, | ||
@@ -130,4 +154,5 @@ omitEmptyValues, | ||
notEmpty, | ||
rejectWithCode, | ||
}, | ||
types | ||
); |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
46894
13
658
1
+ Addedhm-def@0.2.1(transitive)
+ Addedramda-fantasy@0.8.0(transitive)
- Removedhm-def@0.1.2(transitive)
- Removedramda@0.23.0(transitive)
Updatedhm-def@^0.2.0