boxed-immutable
Advanced tools
Comparing version 0.5.0 to 0.5.2
153
lib/util.js
@@ -5,2 +5,22 @@ "use strict"; | ||
const isString = require('lodash.isstring'); | ||
const utilStringWrap = require('util-string-wrap'); | ||
const resolveFunctionArg = utilStringWrap.resolveFunctionArg; | ||
const ifStartsWith = utilStringWrap.ifStartsWith; | ||
const ifEndsWith = utilStringWrap.ifEndsWith; | ||
const ifWrappedWith = utilStringWrap.ifWrappedWith; | ||
const startsWith = utilStringWrap.startsWith; | ||
const endsWith = utilStringWrap.endsWith; | ||
const wrappedWith = utilStringWrap.wrappedWith; | ||
const removePrefix = utilStringWrap.removePrefix; | ||
const removeSuffix = utilStringWrap.removeSuffix; | ||
const unwrap = utilStringWrap.unwrap; | ||
const prefixWith = utilStringWrap.prefixWith; | ||
const suffixWith = utilStringWrap.suffixWith; | ||
const wrapWith = utilStringWrap.wrapWith; | ||
const prefixOnce = utilStringWrap.prefixOnce; | ||
const suffixOnce = utilStringWrap.suffixOnce; | ||
const wrapOnce = utilStringWrap.wrapOnce; | ||
const removePrefixFunc = utilStringWrap.removePrefixFunc; | ||
const removeSuffixFunc = utilStringWrap.removeSuffixFunc; | ||
const unwrapFunc = utilStringWrap.unwrapFunc; | ||
@@ -151,116 +171,35 @@ const UNDEFINED = void 0; | ||
module.exports.resolveArg = resolveArg; | ||
function resolveArg(arg) { | ||
return isFunction(arg) ? arg.apply(undefined, Array.prototype.slice.call(arguments, 1)) : arg; | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.resolveFunctionArg = resolveFunctionArg; | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.ifStartsWith = ifStartsWith; | ||
function ifStartsWith(arg, prefix, onTrue, onFalse) { | ||
return (prefix.length && arg.length >= prefix.length && arg.substr(0, prefix.length) === prefix) | ||
? resolveArg(onTrue, arg, prefix) | ||
: resolveArg(onFalse, arg, prefix); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.ifEndsWith = ifEndsWith; | ||
function ifEndsWith(arg, suffix, onTrue, onFalse) { | ||
return (suffix.length && arg.length >= suffix.length && arg.substr(arg.length - suffix.length) === suffix) | ||
? resolveArg(onTrue, arg, suffix) | ||
: resolveArg(onFalse, arg, suffix); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.ifWrappedWith = ifWrappedWith; | ||
function ifWrappedWith(arg, prefix, suffix, onTrue, onFalse) { | ||
return (arg.length >= prefix.length + suffix.length && startsWith(prop, prefix) && endsWith(prop, suffix)) | ||
? resolveArg(onTrue, arg, prefix, suffix) | ||
: resolveArg(onFalse, arg, prefix, suffix); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.startsWith = startsWith; | ||
function startsWith(arg, prefix) { | ||
return ifStartsWith(arg, prefix, true, false); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.endsWith = endsWith; | ||
function endsWith(arg, suffix) { | ||
return ifEndsWith(arg, suffix, true, false); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.wrappedWith = wrappedWith; | ||
function wrappedWith(arg, prefix, suffix) { | ||
return ifWrappedWith(arg, prefix, suffix, true, false); | ||
} | ||
function removePrefixFunc(arg, prefix) { | ||
return arg.substring(prefix.length, arg.length); | ||
} | ||
function removeSuffixFunc(arg, suffix) { | ||
return arg.substring(0, arg.length - suffix.length); | ||
} | ||
function unwrapFunc(arg, prefix, suffix) { | ||
return arg.substring(prefix.length, arg.length - suffix.length); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.removePrefix = removePrefix; | ||
function removePrefix(arg, prefix) { | ||
return ifStartsWith(arg, prefix, removePrefixFunc, arg); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.removeSuffix = removeSuffix; | ||
function removeSuffix(arg, suffix) { | ||
return ifEndsWith(arg, suffix, removeSuffixFunc, arg); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.unwrap = unwrap; | ||
function unwrap(arg, prefix, suffix) { | ||
return ifWrappedWith(arg, prefix, suffix, unwrapFunc, arg); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.prefixWith = prefixWith; | ||
function prefixWith(arg, prefix) { | ||
return prefix + arg; | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.suffixWith = suffixWith; | ||
function suffixWith(arg, suffix) { | ||
return arg + suffix; | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.wrapWith = wrapWith; | ||
function wrapWith(arg, prefix, suffix) { | ||
return prefix + arg + suffix; | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.prefixOnce = prefixOnce; | ||
function prefixOnce(arg, prefix) { | ||
return ifStartsWith(arg, prefix, arg, prefixWith); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.suffixOnce = suffixOnce; | ||
function suffixOnce(prop, suffix) { | ||
return ifEndsWith(arg, suffix, arg, prefixWith); | ||
} | ||
/** @deprecated, use require('util-string-wrap') instead */ | ||
module.exports.wrapOnce = wrapOnce; | ||
function wrapOnce(arg, prefix, suffix) { | ||
return ifWrappedWith(arg, prefix, suffix, arg, wrappedWith); | ||
} | ||
module.exports.firstDefined = firstDefined; | ||
@@ -450,4 +389,4 @@ | ||
const arg = this; | ||
if (!isObjectLike(arg)) return false; | ||
if (!isObjectLike(arg)) return false; | ||
if (!isValid(exclude)) { | ||
@@ -706,3 +645,3 @@ const keys = Object.keys(arg); | ||
} else if (levels > 1 && isObjectLike(dstValue) && !isArray(dstValue)) { | ||
// cannot deep merge arrays, would just mess up the values | ||
// cannot deep merge arrays, would just mess up the values | ||
newValue = mergeDefaults.call(dstValue, value, levels - 1, isImmutable, deepCloneSrc); | ||
@@ -1092,18 +1031,18 @@ } | ||
BoxedOutArray.prototype.eachRev = eachRev; | ||
// BoxedOutArray.prototype.every = objEvery; | ||
// BoxedOutArray.prototype.every = objEvery; | ||
BoxedOutArray.prototype.everyProp = objEvery; | ||
// BoxedOutArray.prototype.filter = objFilter; | ||
// BoxedOutArray.prototype.filter = objFilter; | ||
BoxedOutArray.prototype.filteredProps = objFiltered; | ||
BoxedOutArray.prototype.filterProps = objFilter; | ||
BoxedOutArray.prototype.hasOwnProperties = hasOwnProperties; | ||
// BoxedOutArray.prototype.map = objMap; | ||
// BoxedOutArray.prototype.map = objMap; | ||
BoxedOutArray.prototype.mappedProps = objMapped; | ||
BoxedOutArray.prototype.mapProps = objMap; | ||
BoxedOutArray.prototype.mergeDefaults = mergeDefaults; | ||
// BoxedOutArray.prototype.reduce = objReduce; | ||
// BoxedOutArray.prototype.reduce = objReduce; | ||
BoxedOutArray.prototype.reduceProps = objReduce; | ||
BoxedOutArray.prototype.reducePropsLeft = objReduceLeft; | ||
BoxedOutArray.prototype.reducePropsRight = objReduceRight; | ||
// BoxedOutArray.prototype.reduceRight = objReduceRight; | ||
// BoxedOutArray.prototype.some = objSome; | ||
// BoxedOutArray.prototype.reduceRight = objReduceRight; | ||
// BoxedOutArray.prototype.some = objSome; | ||
BoxedOutArray.prototype.someProps = objSome; | ||
@@ -1110,0 +1049,0 @@ |
{ | ||
"name": "boxed-immutable", | ||
"version": "0.5.0", | ||
"version": "0.5.2", | ||
"private": false, | ||
@@ -16,3 +16,4 @@ "description": "Immutable proxy wrapper with exception free access to nested properties and auto-instantiation of intermediate containers when nested properties are defined", | ||
"lodash.isfunction": "^3.0.9", | ||
"lodash.isstring": "^4.0.1" | ||
"lodash.isstring": "^4.0.1", | ||
"util-string-wrap": "^0.1.0" | ||
}, | ||
@@ -19,0 +20,0 @@ "devDependencies": { |
@@ -5,3 +5,5 @@ # Version History | ||
- [Next: 0.4.3](#next-043) | ||
- [0.5.2](#052) | ||
- [0.5.0](#050) | ||
- [0.4.3](#043) | ||
- [Next: 0.4.2](#next-042) | ||
@@ -25,7 +27,16 @@ - [Next: 0.4.0](#next-040) | ||
## Next: 0.4.3 | ||
## 0.5.2 | ||
* Change: factor out string wrap related util functions to own module `util-string-wrap`, these | ||
are re-exported from util and marked deprecated for now. | ||
## 0.5.0 | ||
* Change: rename util functions | ||
## 0.4.3 | ||
* Add: `util.firstValid(args)` | ||
## Next: 0.4.2 | ||
## Next: 0.4.2 | ||
@@ -38,7 +49,7 @@ * Add: `$_array` to always return a boxed-out proxy of an array value, non-array values | ||
## Next: 0.4.0 | ||
## Next: 0.4.0 | ||
* Change: Remove "" as array end and match all transforms. Use only "_$" instead to prevent "" | ||
from not being usable as a general property. | ||
* Fix: set prop did not unbox boxed values which were passed in. | ||
* Fix: set prop did not unbox boxed values which were passed in. | ||
* Add: `.$_path` and `.path_$` take string argument and interpret is as a nested property path, | ||
@@ -51,3 +62,3 @@ return final proxy or value. | ||
## 0.3.2 | ||
## 0.3.2 | ||
@@ -61,3 +72,3 @@ * Add: `.withBoxOptions(options)` function to box creation functions so that a transforms | ||
## 0.3.0 | ||
## 0.3.0 | ||
@@ -72,15 +83,15 @@ * Change: completely reworked the concept and implementation to make it less error prone and | ||
## 0.2.8 | ||
## 0.2.8 | ||
* Add: `boxedValue_$[""] = value;` as a synonym for `boxedValue_$[_$] = value;` | ||
## 0.2.6 | ||
## 0.2.6 | ||
* Add: name to Boxed.boxedWith so ._$ function has a name | ||
## 0.2.4 | ||
## 0.2.4 | ||
* Fix: result for non-object, or function for `getOwnPropertyDescriptor()` | ||
## 0.2.2 | ||
## 0.2.2 | ||
@@ -91,3 +102,3 @@ * Fix: exception if `getOwnPropertyNames()` is called on boxed object with null or undefined | ||
## 0.2.0 | ||
## 0.2.0 | ||
@@ -118,3 +129,3 @@ * Fix: forEach$ did not box item passed to callback. | ||
## 0.1.6 | ||
## 0.1.6 | ||
@@ -121,0 +132,0 @@ * Fix: setting null values would cause NPE. |
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
29
290485
3
7031
+ Addedutil-string-wrap@^0.1.0
+ Addedutil-string-wrap@0.1.6(transitive)