Comparing version 3.0.5 to 3.0.6
{ | ||
"name": "js-data", | ||
"description": "Robust, framework-agnostic in-memory data store.", | ||
"version": "3.0.5", | ||
"version": "3.0.6", | ||
"homepage": "http://www.js-data.io", | ||
@@ -6,0 +6,0 @@ "repository": { |
118
src/utils.js
@@ -15,3 +15,3 @@ /** | ||
const INFINITY = 1 / 0 | ||
const MAX_INTEGER = 1.7976931348623157e+308 | ||
const MAX_INTEGER = 1.7976931348623157e308 | ||
const BOOL_TAG = '[object Boolean]' | ||
@@ -28,4 +28,10 @@ const DATE_TAG = '[object Date]' | ||
const ERRORS = { | ||
'400' () { return `expected: ${arguments[0]}, found: ${arguments[2] ? arguments[1] : typeof arguments[1]}` }, | ||
'404' () { return `${arguments[0]} not found` } | ||
'400' () { | ||
return `expected: ${arguments[0]}, found: ${ | ||
arguments[2] ? arguments[1] : typeof arguments[1] | ||
}` | ||
}, | ||
'404' () { | ||
return `${arguments[0]} not found` | ||
} | ||
} | ||
@@ -40,3 +46,3 @@ | ||
if (value === INFINITY || value === -INFINITY) { | ||
const sign = (value < 0 ? -1 : 1) | ||
const sign = value < 0 ? -1 : 1 | ||
return sign * MAX_INTEGER | ||
@@ -53,3 +59,3 @@ } | ||
const isPlainObject = function (value) { | ||
return (!!value && typeof value === 'object' && value.constructor === Object) | ||
return !!value && typeof value === 'object' && value.constructor === Object | ||
} | ||
@@ -103,3 +109,8 @@ | ||
utils.forOwn(src, function (value, key) { | ||
if (key && dest[key] === undefined && !utils.isFunction(value) && key.indexOf('_') !== 0) { | ||
if ( | ||
key && | ||
dest[key] === undefined && | ||
!utils.isFunction(value) && | ||
key.indexOf('_') !== 0 | ||
) { | ||
dest[key] = value | ||
@@ -146,3 +157,8 @@ } | ||
optsCopy.with.forEach(function (relation, i) { | ||
if (relation && relation.indexOf(containedName) === 0 && relation.length >= containedName.length && relation[containedName.length] === '.') { | ||
if ( | ||
relation && | ||
relation.indexOf(containedName) === 0 && | ||
relation.length >= containedName.length && | ||
relation[containedName.length] === '.' | ||
) { | ||
optsCopy.with[i] = relation.substr(containedName.length + 1) | ||
@@ -234,5 +250,6 @@ } else { | ||
const diff = utils.diffObjects(newObject, oldObject, opts) | ||
const diffCount = Object.keys(diff.added).length + | ||
Object.keys(diff.removed).length + | ||
Object.keys(diff.changed).length | ||
const diffCount = | ||
Object.keys(diff.added).length + | ||
Object.keys(diff.removed).length + | ||
Object.keys(diff.changed).length | ||
return diffCount > 0 | ||
@@ -303,3 +320,10 @@ }, | ||
} else { | ||
to = utils.copy(from, Object.create(Object.getPrototypeOf(from)), stackFrom, stackTo, blacklist, plain) | ||
to = utils.copy( | ||
from, | ||
Object.create(Object.getPrototypeOf(from)), | ||
stackFrom, | ||
stackTo, | ||
blacklist, | ||
plain | ||
) | ||
} | ||
@@ -310,3 +334,6 @@ } | ||
if (from === to) { | ||
throw utils.err(`${DOMAIN}.copy`)(500, 'Cannot copy! Source and destination are identical.') | ||
throw utils.err(`${DOMAIN}.copy`)( | ||
500, | ||
'Cannot copy! Source and destination are identical.' | ||
) | ||
} | ||
@@ -332,3 +359,10 @@ | ||
for (i = 0; i < from.length; i++) { | ||
result = utils.copy(from[i], null, stackFrom, stackTo, blacklist, plain) | ||
result = utils.copy( | ||
from[i], | ||
null, | ||
stackFrom, | ||
stackTo, | ||
blacklist, | ||
plain | ||
) | ||
if (utils.isObject(from[i])) { | ||
@@ -353,3 +387,10 @@ stackFrom.push(from[i]) | ||
} | ||
result = utils.copy(from[key], null, stackFrom, stackTo, blacklist, plain) | ||
result = utils.copy( | ||
from[key], | ||
null, | ||
stackFrom, | ||
stackTo, | ||
blacklist, | ||
plain | ||
) | ||
if (utils.isObject(from[key])) { | ||
@@ -537,3 +578,6 @@ stackFrom.push(from[key]) | ||
const prefix = `[${domain}:${target}] ` | ||
let message = ERRORS[code].apply(null, Array.prototype.slice.call(arguments, 1)) | ||
let message = ERRORS[code].apply( | ||
null, | ||
Array.prototype.slice.call(arguments, 1) | ||
) | ||
message = `${prefix}${message} | ||
@@ -567,4 +611,8 @@ http://www.js-data.io/v3.0/docs/errors#${code}` | ||
if (!getter && !setter) { | ||
getter = function () { return _events } | ||
setter = function (value) { _events = value } | ||
getter = function () { | ||
return _events | ||
} | ||
setter = function (value) { | ||
_events = value | ||
} | ||
} | ||
@@ -847,3 +895,3 @@ Object.defineProperties(target, { | ||
*/ | ||
'get': function (object, prop) { | ||
get: function (object, prop) { | ||
if (!prop) { | ||
@@ -855,5 +903,7 @@ return | ||
while (prop = parts.shift()) { // eslint-disable-line | ||
while ((prop = parts.shift())) { | ||
// eslint-disable-line | ||
object = object[prop] | ||
if (object == null) { // eslint-disable-line | ||
if (object == null) { | ||
// eslint-disable-line | ||
return | ||
@@ -922,2 +972,4 @@ } | ||
} | ||
array1 = Array.isArray(array1) ? array1 : [array1] | ||
array2 = Array.isArray(array2) ? array2 : [array2] | ||
const result = [] | ||
@@ -980,3 +1032,6 @@ let item | ||
for (var i = 0; i < blacklist.length; i++) { | ||
if ((toStr(blacklist[i]) === REGEXP_TAG && blacklist[i].test(prop)) || blacklist[i] === prop) { | ||
if ( | ||
(toStr(blacklist[i]) === REGEXP_TAG && blacklist[i].test(prop)) || | ||
blacklist[i] === prop | ||
) { | ||
matches = prop | ||
@@ -1024,3 +1079,3 @@ return !!matches | ||
isDate (value) { | ||
return (value && typeof value === 'object' && toStr(value) === DATE_TAG) | ||
return value && typeof value === 'object' && toStr(value) === DATE_TAG | ||
}, | ||
@@ -1106,3 +1161,6 @@ | ||
const type = typeof value | ||
return type === 'number' || (value && type === 'object' && toStr(value) === NUMBER_TAG) | ||
return ( | ||
type === 'number' || | ||
(value && type === 'object' && toStr(value) === NUMBER_TAG) | ||
) | ||
}, | ||
@@ -1186,3 +1244,6 @@ | ||
isString (value) { | ||
return typeof value === 'string' || (value && typeof value === 'object' && toStr(value) === STRING_TAG) | ||
return ( | ||
typeof value === 'string' || | ||
(value && typeof value === 'object' && toStr(value) === STRING_TAG) | ||
) | ||
}, | ||
@@ -1246,3 +1307,4 @@ | ||
} | ||
const prefix = `${level.toUpperCase()}: (${this.name || this.constructor.name})` | ||
const prefix = `${level.toUpperCase()}: (${this.name || | ||
this.constructor.name})` | ||
if (utils.isFunction(console[level])) { | ||
@@ -1599,5 +1661,7 @@ console[level](prefix, ...args) | ||
while (path = parts.shift()) { // eslint-disable-line | ||
while ((path = parts.shift())) { | ||
// eslint-disable-line | ||
object = object[path] | ||
if (object == null) { // eslint-disable-line | ||
if (object == null) { | ||
// eslint-disable-line | ||
return | ||
@@ -1604,0 +1668,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
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
2906548
40196