vigour-util
Advanced tools
Comparing version 1.3.1 to 1.3.2
'use strict' | ||
/** | ||
* @function define | ||
* helper for Object.defineProperty on base classes | ||
* always sets configurable to true | ||
*/ | ||
var define = Object.defineProperty | ||
@@ -3,0 +8,0 @@ module.exports = function () { |
'use strict' | ||
/** | ||
* @function getReference | ||
* Get's the referenced object | ||
* @param {object} obj - the reference we want to follow | ||
* @returns {object} The referenced object or undefined | ||
*/ | ||
module.exports = function (obj) { | ||
@@ -3,0 +9,0 @@ var referenced = obj.__input |
'use strict' | ||
var email = /^[a-zA-Z0-9._%+-]+@[A-Za-z0-9.-]+\.[a-zA-Z]{2,20}$/ | ||
var email = /^([^.](?![a-zA-Z0-9!#$%&'*+\-/=?^_`{|}~]+\.\.)([a-zA-Z0-9!#$%&'*+\-/=?^_`{|}~.]+[^.])|([a-zA-Z0-9]))@([A-Za-z0-9-]{1,64}\.){1,10}[a-zA-Z]{2,64}$/ | ||
/** | ||
* @function isEmail | ||
* Checks whether provided parameter looks like a valid e-mail address | ||
* @param {string} val - the string to process | ||
* @returns {boolean} `true` if `val` is a valid e-mail address, `false` otherwise | ||
*/ | ||
module.exports = function (val) { | ||
return typeof val === 'string' && email.test(val) | ||
return typeof val === 'string' && ( | ||
email.test(val) && val.indexOf('@') < 65 && val.length < 255 | ||
) | ||
} |
'use strict' | ||
/** | ||
* @function isEmpty | ||
* Checks if a `Base` object is empty | ||
* @param {object} obj - the object to check for emptiness | ||
* @returns {boolean} `true` if `obj` is considered empty, `false` otherwise | ||
*/ | ||
module.exports = function isEmpty (obj) { | ||
var ret = true | ||
if (obj.each) { | ||
obj.each(function (property, key) { | ||
if (property.__input !== null) { | ||
return false | ||
return (ret = false) | ||
} | ||
@@ -14,3 +21,3 @@ }) | ||
} | ||
return true | ||
return ret | ||
} |
'use strict' | ||
var isHash = /^[a-z\d]{5,7}$/ | ||
module.exports = (val) => isHash.test(val) | ||
var isNumber = require('./number') | ||
module.exports = (val) => !isNumber(val) && isHash.test(val) |
'use strict' | ||
var isNumber = require('lodash.isnumber') | ||
var isNumber = require('lodash.isfinite') | ||
module.exports = isNumber |
@@ -6,3 +6,3 @@ 'use strict' | ||
if (val === null || val === void 0 || val === false) { | ||
return | ||
return false | ||
} | ||
@@ -17,11 +17,25 @@ var length = val.length | ||
if (length === 1) { | ||
return | ||
return false | ||
} | ||
i = 1 | ||
} | ||
var foundE = false | ||
var foundPeriod = false | ||
for (; i < length; i++) { | ||
var c = val.charAt(i) | ||
// bit range is outside number range | ||
if (c <= '/' || c >= ':') { | ||
return | ||
if ((c <= '/' || c >= ':')) { | ||
if (c === 'e') { | ||
if (foundE) { | ||
return false | ||
} | ||
foundE = true | ||
} else if (c === '.') { | ||
if (foundPeriod) { | ||
return false | ||
} | ||
foundPeriod = true | ||
} else { | ||
return false | ||
} | ||
} | ||
@@ -28,0 +42,0 @@ } |
'use strict' | ||
module.exports = function isRemoved (base) { | ||
if (base === null) { | ||
return true | ||
} | ||
for (var key in base) { | ||
@@ -4,0 +7,0 @@ // use each for this one |
@@ -6,16 +6,32 @@ 'use strict' | ||
var Readable = stream.Readable | ||
// transform, duplex, writable, readabe | ||
module.exports = exports = function (val) { | ||
return val && typeof val === 'object' && ( | ||
exports.writable(val) || | ||
exports.readable(val) | ||
) | ||
} | ||
exports.readable = function (val) { | ||
return val && ( | ||
val instanceof Readable || | ||
val instanceof Duplex || | ||
val instanceof Readable || | ||
val instanceof Writable | ||
( | ||
val.readable === true && | ||
typeof val.push === 'function' && | ||
typeof val.on === 'function' | ||
) | ||
) | ||
} | ||
exports.readable = function (val) { | ||
exports.writable = function (val) { | ||
return val && ( | ||
val instanceof Readable || val instanceof Duplex | ||
(val instanceof Writable) || | ||
(val instanceof Duplex) || | ||
( | ||
val.writable === true && | ||
typeof val.pipe === 'function' && | ||
typeof val.on === 'function' | ||
) | ||
) | ||
} |
@@ -5,2 +5,3 @@ 'use strict' | ||
module.exports = function merge (a, b, checked) { | ||
console.log('WARNING: `vigour-util/merge` is deprecated, consider using `lodash.merge` instead') | ||
if (checked || typeof a === OBJ) { | ||
@@ -7,0 +8,0 @@ for (let key in b) { |
{ | ||
"name": "vigour-util", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"author": "Vigour.io <dev@vigour.io>", | ||
@@ -20,3 +20,4 @@ "scripts": { | ||
"dependencies": { | ||
"lodash.isnumber": "3.0.3" | ||
"lodash.isfinite": "^3.3.0", | ||
"lodash.set": "^4.0.0" | ||
}, | ||
@@ -39,4 +40,5 @@ "main": "./", | ||
"devDependencies": { | ||
"tape": "^4.5.1" | ||
"tape": "^4.5.1", | ||
"vigour-base": "^1.2.2" | ||
} | ||
} |
'use strict' | ||
module.exports = function setWithPath (obj, path, val, i) { | ||
console.log('WARNING: `setwithpath` is deprecated') | ||
if (!i) { | ||
@@ -5,0 +6,0 @@ i = 0 |
'use strict' | ||
require('./get') | ||
require('./is') | ||
require('./path') | ||
require('./uuid') | ||
require('./descriptors') | ||
require('./flatten') | ||
require('./unflatten') | ||
require('./hash') | ||
require('./define') |
'use strict' | ||
require('./email') | ||
require('./empty') | ||
require('./url') | ||
require('./hash') | ||
require('./numberlike') | ||
require('./plainobj') | ||
require('./removed') | ||
require('./stream') | ||
require('./url') |
@@ -6,3 +6,3 @@ 'use strict' | ||
var testCases = [ | ||
// ['url',expectedResult] | ||
// ['url', expectedResult] | ||
['string', false], | ||
@@ -17,3 +17,5 @@ ['domain.ext', true], | ||
['192.11.222.444', true], | ||
['2001:0db8:0000:0042:0000:8a2e:0370:7334', true] | ||
['2001:0db8:0000:0042:0000:8a2e:0370:7334', true], | ||
['ws://localhost:8080', true], | ||
['wss://etc.com', true] | ||
] | ||
@@ -24,4 +26,4 @@ | ||
testCases.forEach(function (item) { | ||
t.equals(isURL(item[0]), item[1], item[0]) | ||
t.equals(isURL(item[0]), item[1], 'isURL(' + item[0] + ') === ' + item[1]) | ||
}) | ||
}) |
'use strict' | ||
var _set = require('lodash.set') | ||
/** | ||
@@ -13,18 +16,9 @@ * @function Unflatten an object with delimited keys | ||
separator = separator || '.' | ||
var dotSep = (separator === '.') | ||
var re = new RegExp(separator, 'g') | ||
var newObj = {} | ||
each(obj, function (val, keys) { | ||
var partitions = keys.split(separator) | ||
var result = newObj | ||
var len = partitions.length - 1 | ||
each(partitions, function (keys, i) { | ||
result = result[keys] = (i === len ? val : (result[keys] || {})) | ||
}) | ||
}) | ||
for (let path in obj) { | ||
_set(newObj, dotSep ? path : path.replace(re, '.'), obj[path]) | ||
} | ||
return newObj | ||
} | ||
function each (obj, fn) { | ||
for(var i in obj) { | ||
fn(obj, obj[i]) | ||
} | ||
} |
@@ -5,2 +5,5 @@ 'use strict' | ||
var stamp = Date.now() | ||
exports.val = hash('n-' + process.pid + '-' + stamp + '-' + rand) | ||
exports.generate = function () { | ||
return hash('n-' + process.pid + '-' + stamp + '-' + rand) | ||
} | ||
exports.val = exports.generate() |
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
Network access
Supply chain riskThis module accesses the network.
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
55531
52
1438
1
249
2
2
1
+ Addedlodash.isfinite@^3.3.0
+ Addedlodash.set@^4.0.0
+ Addedlodash.isfinite@3.3.2(transitive)
+ Addedlodash.set@4.3.2(transitive)
- Removedlodash.isnumber@3.0.3
- Removedlodash.isnumber@3.0.3(transitive)