prototypes
Advanced tools
Comparing version 0.4.3 to 1.0.0
@@ -82,3 +82,3 @@ 'use strict'; | ||
/** | ||
* Returns the intersection of an array with another given | ||
* Returns the intersection of the array with the parameter. | ||
*/ | ||
@@ -100,3 +100,3 @@ newArray.intersect = function (array) { | ||
/** | ||
* Returns the difference between the array and another given | ||
* Returns the difference between the array and the parameter. | ||
*/ | ||
@@ -106,10 +106,18 @@ newArray.difference = function (array) { | ||
var index = -1; | ||
while (++index < this.length) { | ||
if (!array.contains(this[index])) { | ||
diff.push(this[index]); | ||
} | ||
while (++index < this.length) { | ||
if (!array.contains(this[index])) { | ||
diff.push(this[index]); | ||
} | ||
return diff; | ||
} | ||
return diff; | ||
}; | ||
/** | ||
* Returns the array flattened just one level. | ||
*/ | ||
newArray.concatAll = function() | ||
{ | ||
return [].concat.apply([], this); | ||
}; | ||
// add new object functions as properties | ||
@@ -116,0 +124,0 @@ core.addProperties(Array.prototype, newArray); |
{ | ||
"name": "prototypes", | ||
"version": "0.4.3", | ||
"version": "1.0.0", | ||
"description": "Some common prototypes for node.js: string.startsWith(), object.countProperties() and more. Facilities for functional programming with objects: object.forEach(), object.filter(). Functions are added safely using Object.defineProperty().", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/alexfernandez/prototypes", |
@@ -340,2 +340,11 @@ [![Build Status](https://secure.travis-ci.org/alexfernandez/prototypes.png)](http://travis-ci.org/alexfernandez/prototypes) | ||
### array.concatAll() | ||
Flattens just one level of nested array. Example: | ||
``` | ||
[1, 2, [3, 4, [5, 6]]].concatAll(); | ||
\=> [1, 2, 3, 4, [5, 6]] | ||
``` | ||
### Array.toArray(object) | ||
@@ -342,0 +351,0 @@ |
@@ -103,2 +103,9 @@ 'use strict'; | ||
function testConcatAll(callback) | ||
{ | ||
var result = [1, 2, [3, 4, [5, 6]]].concatAll(); | ||
testing.assertEquals(result.length, 5, 'Should only flatten one level', callback); | ||
testing.success(callback); | ||
} | ||
/** | ||
@@ -117,2 +124,3 @@ * Run package tests. | ||
testToArray, | ||
testConcatAll, | ||
]; | ||
@@ -119,0 +127,0 @@ testing.run(tests, callback); |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
43107
1130
0
445