Comparing version 2.4.2 to 2.4.3
# Changelog | ||
## v2.4.3 | ||
* Better `tree/cursor.splice` ([@jrust](https://github.com/jrust)). | ||
## v2.4.2 | ||
@@ -4,0 +8,0 @@ |
@@ -603,3 +603,3 @@ /** | ||
*/ | ||
Baobab.VERSION = '2.4.2'; | ||
Baobab.VERSION = '2.4.3'; | ||
module.exports = exports['default']; |
@@ -592,3 +592,7 @@ /* eslint eqeqeq: 0 */ | ||
function splice(array, startIndex, nb) { | ||
if (nb === undefined) nb = array.length - startIndex;else if (nb === null) nb = 0;else if (Number.isNaN(Number.parseInt(nb, 10))) throw new Error('argument nb ' + nb + ' can not be parsed into a number!'); | ||
for (var _len2 = arguments.length, elements = Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) { | ||
elements[_key2 - 3] = arguments[_key2]; | ||
} | ||
if (nb === undefined && arguments.length === 2) nb = array.length - startIndex;else if (nb === null || nb === undefined) nb = 0;else if (isNaN(+nb)) throw new Error('argument nb ' + nb + ' can not be parsed into a number!'); | ||
nb = Math.max(0, nb); | ||
@@ -603,7 +607,2 @@ | ||
// Positive index | ||
for (var _len2 = arguments.length, elements = Array(_len2 > 3 ? _len2 - 3 : 0), _key2 = 3; _key2 < _len2; _key2++) { | ||
elements[_key2 - 3] = arguments[_key2]; | ||
} | ||
if (startIndex >= 0) return array.slice(0, startIndex).concat(elements).concat(array.slice(startIndex + nb)); | ||
@@ -610,0 +609,0 @@ |
@@ -118,3 +118,3 @@ /** | ||
if (!type.array(target) || target.length < 1) return false; | ||
if (target.length > 1 && Number.isNaN(Number.parseInt(target[1], 10))) return false; | ||
if (target.length > 1 && isNaN(+target[1])) return false; | ||
@@ -121,0 +121,0 @@ return anyOf(target[0], ['number', 'function', 'object']); |
{ | ||
"name": "baobab", | ||
"version": "2.4.2", | ||
"version": "2.4.3", | ||
"description": "JavaScript persistent data tree with cursors.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/baobab.js", |
@@ -594,2 +594,2 @@ /** | ||
*/ | ||
Baobab.VERSION = '2.4.2'; | ||
Baobab.VERSION = '2.4.3'; |
@@ -573,7 +573,7 @@ /* eslint eqeqeq: 0 */ | ||
export function splice(array, startIndex, nb, ...elements) { | ||
if (nb === undefined) | ||
if (nb === undefined && arguments.length === 2) | ||
nb = array.length - startIndex; | ||
else if (nb === null) | ||
else if (nb === null || nb === undefined) | ||
nb = 0; | ||
else if (Number.isNaN(Number.parseInt(nb, 10))) | ||
else if (isNaN(+nb)) | ||
throw new Error(`argument nb ${nb} can not be parsed into a number!`); | ||
@@ -580,0 +580,0 @@ nb = Math.max(0, nb); |
@@ -117,3 +117,3 @@ /** | ||
return false; | ||
if (target.length > 1 && Number.isNaN(Number.parseInt(target[1], 10))) | ||
if (target.length > 1 && isNaN(+target[1])) | ||
return false; | ||
@@ -120,0 +120,0 @@ |
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
206025