Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bloody-collections

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bloody-collections - npm Package Compare versions

Comparing version 0.6.0 to 1.0.0

LICENSE.md

38

index.js
module.exports = {
each : require("./lib/each")
, extend : require("./lib/extend")
, filter : require("./lib/filter")
, reject : require("./lib/reject")
, map : require("./lib/map")
, pluck : require("./lib/pluck")
, reduce : require("./lib/reduce")
, reduceRight : require("./lib/reduceRight")
, getKeys : require("./lib/getKeys")
, getValues : require("./lib/getValues")
, getPairs : require("./lib/getPairs")
, getSize : require("./lib/getSize")
, indexOf : require("./lib/indexOf")
, contains : require("./lib/contains")
, clone : require("./lib/clone")
, lastIndexOf : require("./lib/lastIndexOf")
, range : require("./lib/range")
, iterator : require("./lib/iterator")
, zip : require("./lib/zip")
each : require("./lib/each"),
extend : require("./lib/extend"),
filter : require("./lib/filter"),
reject : require("./lib/reject"),
map : require("./lib/map"),
pluck : require("./lib/pluck"),
reduce : require("./lib/reduce"),
reduceRight : require("./lib/reduceRight"),
getKeys : require("./lib/getKeys"),
getValues : require("./lib/getValues"),
getPairs : require("./lib/getPairs"),
getSize : require("./lib/getSize"),
indexOf : require("./lib/indexOf"),
contains : require("./lib/contains"),
clone : require("./lib/clone"),
lastIndexOf : require("./lib/lastIndexOf"),
range : require("./lib/range"),
iterator : require("./lib/iterator"),
zip : require("./lib/zip")
}
module.exports = [
function(fn, thisValue){
return function(){
return fn.call(thisValue)
}
function(fn, thisValue){
return function(){
return fn.call(thisValue)
}
, function(fn, thisValue){
return function(a){
return fn.call(thisValue, a)
}
},
function(fn, thisValue){
return function(a){
return fn.call(thisValue, a)
}
, function(fn, thisValue){
return function(a,b){
return fn.call(thisValue, a, b)
}
},
function(fn, thisValue){
return function(a,b){
return fn.call(thisValue, a, b)
}
, function(fn, thisValue){
return function(a,b,c){
return fn.call(thisValue, a, b, c)
}
},
function(fn, thisValue){
return function(a,b,c){
return fn.call(thisValue, a, b, c)
}
, function(fn, thisValue){
return function(a,b,c,d){
return fn.call(thisValue, a, b, c, d)
}
},
function(fn, thisValue){
return function(a,b,c,d){
return fn.call(thisValue, a, b, c, d)
}
, function(fn, thisValue){
return function(){
return fn.apply(thisValue, arguments)
}
},
function(fn, thisValue){
return function(){
return fn.apply(thisValue, arguments)
}
}
]
var extend = require("./extend")
, each = require("./each")
, ARRAY_CLASS = "[object Array]"
, OBJECT_CLASS = "[object Object]"
, _toString = {}.toString
, nativeConcat = [].concat
, clonable = {}
var each = require("./each")
var ARRAY_CLASS = "[object Array]"
var OBJECT_CLASS = "[object Object]"
var _toString = {}.toString
var nativeConcat = [].concat
var clonable = {}

@@ -9,0 +9,0 @@ clonable[ARRAY_CLASS] = 1

var getKeys = require("./getKeys")
, createCallback = require("./createCallback")
, isArrayLike = require("./isArrayLike")
var createCallback = require("./createCallback")
var isArrayLike = require("./isArrayLike")
module.exports = function(collection, fn, thisValue){
var index = -1, length
, keys, key
, callback = createCallback(fn, thisValue, 3)
var index = -1
var length
var keys
var key
var callback = createCallback(fn, thisValue, 3)
if(!collection) return

@@ -13,3 +15,5 @@ if(isArrayLike(collection)) {

while(++index < length) {
if(callback(collection[index], index, collection) === false) break
if(callback(collection[index], index, collection) === false) {
break
}
}

@@ -22,4 +26,6 @@ return

key = keys[index]
if(callback(collection[key], key, collection) === false) break
if(callback(collection[key], key, collection) === false) {
break
}
}
}

@@ -10,4 +10,6 @@ var each = require("./each")

function extendCallback(value, key){
if(!this) return false
if(!this) {
return false
}
this[key] = value
}
var getKeys = require("./getKeys")
, createCallback = require("./createCallback")
, isArrayLike = require("./isArrayLike")
var createCallback = require("./createCallback")
var isArrayLike = require("./isArrayLike")
module.exports = function(collection, fn, thisValue){
var index = -1, length
, keys, key
, callback = createCallback(fn, thisValue, 3)
, result, item
if(!collection) return null
var index = -1
var length
var keys
var key
var callback = createCallback(fn, thisValue, 3)
var result
var item
if(!collection) {
return null
}
if(isArrayLike(collection)) {

@@ -12,0 +17,0 @@ length = collection.length

var objectPrototype = Object.prototype
, enumBugProperties = [
"constructor"
, "hasOwnProperty"
, "isPrototypeOf"
, "propertyIsEnumerable",
, "toLocaleString"
, "toString"
, "valueOf"
]
, hasEnumBug = !objectPrototype.propertyIsEnumerable.call({constructor:1}, "constructor")
, _hasOwnProperty = objectPrototype.hasOwnProperty
, hasObjectKeys = typeof Object.keys == "function"
, objectKeys = Object.keys
var enumBugProperties = [
"constructor",
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"toLocaleString",
"toString",
"valueOf"
]
var hasEnumBug = !objectPrototype.propertyIsEnumerable.call(
{constructor : 1},
"constructor"
)
var _hasOwnProperty = objectPrototype.hasOwnProperty
var hasObjectKeys = typeof Object.keys == "function"
var objectKeys = Object.keys
module.exports = function(object){
var index
, keys
, length
, enumKey
if(object == null) return []
if(hasObjectKeys) return objectKeys(object)
var keys
var length
var enumKey
if(object == null) {
return []
}
if(hasObjectKeys) {
return objectKeys(object)
}
keys = []
for(index in object) {
if(_hasOwnProperty.call(object, index)) keys.push(index)
if(_hasOwnProperty.call(object, index)) {
keys.push(index)
}
}

@@ -28,0 +37,0 @@ if(hasEnumBug) {

@@ -5,4 +5,6 @@ var getKeys = require("./getKeys")

var keys = getKeys(object)
, index = -1, length = keys.length
, values = [], key
var index = -1
var length = keys.length
var values = []
var key
while(++index < length) {

@@ -9,0 +11,0 @@ key = keys[index]

var getKeys = require("./getKeys")
, isArrayLike = require("./isArrayLike")
var isArrayLike = require("./isArrayLike")
module.exports = function(object){
if(isArrayLike(object)) return object.length
if(isArrayLike(object)) {
return object.length
}
return getKeys(object).length
}

@@ -5,4 +5,6 @@ var getKeys = require("./getKeys")

var keys = getKeys(object)
, index = -1, length = keys.length
, values = [], key
var index = -1
var length = keys.length
var values = []
var key
while(++index < length) {

@@ -9,0 +11,0 @@ key = keys[index]

module.exports = function(array, value){
var index = -1, length = array.length
var index = -1
var length = array.length
while(++index < length) {
if(array[index] === value) return index
if(array[index] === value) {
return index
}
}
return -1
}

@@ -6,4 +6,8 @@ var _hasOwnProperty = {}.hasOwnProperty

function fn(){
if(++index > array.length) return null
if(!(index in array)) return fn()
if(++index > array.length) {
return null
}
if(!(index in array)) {
return fn()
}
return array[index]

@@ -10,0 +14,0 @@ }

module.exports = function(array, value){
var length = array.length
while(--length > -1) {
if(array[length] === value) return length
if(array[length] === value) {
return length
}
}
return -1
}
var getKeys = require("./getKeys")
, createCallback = require("./createCallback")
, isArrayLike = require("./isArrayLike")
var createCallback = require("./createCallback")
var isArrayLike = require("./isArrayLike")
module.exports = function(collection, fn, thisValue){
var index = -1, length
, keys, key
, callback = createCallback(fn, thisValue, 3)
, result
if(!collection) return null
var index = -1
var length
var keys
var key
var callback = createCallback(fn, thisValue, 3)
var result
if(!collection) {
return null
}
if(isArrayLike(collection)) {

@@ -12,0 +16,0 @@ length = collection.length

var getKeys = require("./getKeys")
, createCallback = require("./createCallback")
, isArrayLike = require("./isArrayLike")
var createCallback = require("./createCallback")
var isArrayLike = require("./isArrayLike")
module.exports = function(collection, propertyName){
var index = -1, length, item
, keys, key
, result
if(!collection) return null
var index = -1
var length
var item
var keys
var key
var result
if(!collection) {
return null
}
if(isArrayLike(collection)) {

@@ -11,0 +16,0 @@ length = collection.length

module.exports = function(start, end, step) {
var range
, index = -1
, length
var index = -1
var length
if(step == null) {

@@ -6,0 +6,0 @@ step = 1

var getKeys = require("./getKeys")
, createCallback = require("./createCallback")
, isArrayLike = require("./isArrayLike")
var createCallback = require("./createCallback")
var isArrayLike = require("./isArrayLike")
module.exports = function(collection, fn, initialValue, thisValue){
var index = -1, length
, keys, key
, callback = createCallback(fn, thisValue, 4)
, result
if(!collection) return null
var index = -1
var length
var keys
var key
var callback = createCallback(fn, thisValue, 4)
var result
if(!collection) {
return null
}
if(isArrayLike(collection)) {

@@ -12,0 +16,0 @@ length = collection.length

var getKeys = require("./getKeys")
, createCallback = require("./createCallback")
, isArrayLike = require("./isArrayLike")
var createCallback = require("./createCallback")
var isArrayLike = require("./isArrayLike")
module.exports = function(collection, fn, initialValue, thisValue){
var length
, keys, key
, callback = createCallback(fn, thisValue, 4)
, result
if(!collection) return null
var keys
var key
var callback = createCallback(fn, thisValue, 4)
var result
if(!collection) {
return null
}
if(isArrayLike(collection)) {

@@ -12,0 +15,0 @@ length = collection.length

var getKeys = require("./getKeys")
, createCallback = require("./createCallback")
, isArrayLike = require("./isArrayLike")
var createCallback = require("./createCallback")
var isArrayLike = require("./isArrayLike")
module.exports = function(collection, fn, thisValue){
var index = -1, length
, keys, key
, callback = createCallback(fn, thisValue, 3)
, result, item
if(!collection) return null
var index = -1
var length
var keys
var key
var callback = createCallback(fn, thisValue, 3)
var result
var item
if(!collection) {
return null
}
if(isArrayLike(collection)) {

@@ -12,0 +17,0 @@ length = collection.length

@@ -5,4 +5,4 @@ var pluck = require("./pluck")

var length = Math.max.apply(Math, pluck(arguments, "length")) || 0
, array = Array(Math.max(0, length))
, index = -1
var array = Array(Math.max(0, length))
var index = -1
while(++index < length) {

@@ -9,0 +9,0 @@ array[index] = pluck(arguments, index)

{
"name" : "bloody-collections",
"repository" : "https://github.com/bloodyowl/collections",
"issues" : "https://github.com/bloodyowl/collections/issues",
"version" : "0.6.0",
"scripts" : {
"test" : "tape test/*.js"
"name": "bloody-collections",
"repository": {
"type": "git",
"url": "https://github.com/bloodyowl/collections"
},
"issues": "https://github.com/bloodyowl/collections/issues",
"version": "1.0.0",
"scripts": {
"test": "tape test/*.js"
},
"devDependencies": {

@@ -15,11 +18,53 @@ "tape": "~2.3.2"

"browsers": {
"ie": [ 6, 7, 8, 9 ],
"firefox": [ 22, 23, 24, 25 ],
"chrome": [ 28, 29, 30, 31 ],
"safari": [ 4, 5.1, 6 ],
"opera": [ 10, 11, 12 ],
"iphone" : [ 6 ],
"ipad" : [ 6 ]
"ie": [
6,
7,
8,
9
],
"firefox": [
22,
23,
24,
25
],
"chrome": [
28,
29,
30,
31
],
"safari": [
4,
5.1,
6
],
"opera": [
10,
11,
12
],
"iphone": [
6
],
"ipad": [
6
]
}
}
},
"description": "[![browser support](https://ci.testling.com/bloodyowl/collections.png)](https://ci.testling.com/bloodyowl/collections)",
"bugs": {
"url": "https://github.com/bloodyowl/collections/issues"
},
"homepage": "https://github.com/bloodyowl/collections",
"main": "index.js",
"directories": {
"test": "test"
},
"dependencies": {
"tape": "~2.3.2",
"coverify": "~1.0.6"
},
"author": "bloodyowl",
"license": "MIT"
}

@@ -5,3 +5,3 @@ # collections

## Install
## install

@@ -12,3 +12,3 @@ ```

## Require
## require

@@ -21,7 +21,7 @@ ```

## API
## api
### `each(collection, fn[, thisValue])`
### each(collection, fn[, thisValue])
Executes `fn` with `[item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`.
Executes `fn` with `[item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`.

@@ -34,3 +34,3 @@ ```javascript

### `extend(source, object)` -> `source`
### extend(source, object) > source

@@ -43,19 +43,19 @@ Pushes every `object` values to `source`

### `filter(collection, fn[, thisValue])` -> `new collection`
### filter(collection, fn[, thisValue]) > new collection
Executes `fn` with `[item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`, and returns an collection filled with item with which `fn` returned a truthy value.
Executes `fn` with `[item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`, and returns an collection filled with item with which `fn` returned a truthy value.
```javascript
filter([1,2,3], function(item){
return !(item % 2)
filter([1,2,3], function(item){
return !(item % 2)
}) // [2]
```
### `reject(collection, fn[, thisValue])` -> `new collection`
### reject(collection, fn[, thisValue]) > new collection
Executes `fn` with `[item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`, and returns an collection filled with item with which `fn` returned a falsy value.
Executes `fn` with `[item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`, and returns an collection filled with item with which `fn` returned a falsy value.
```javascript
reject([1,2,3], function(item){
return !(item % 2)
reject([1,2,3], function(item){
return !(item % 2)
}) // [1,3]

@@ -65,3 +65,3 @@ ```

### `map(collection, fn[, thisValue])` -> `new collection`
### map(collection, fn[, thisValue]) > new collection

@@ -71,3 +71,3 @@ Executes `fn` with `[item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`, and returns an collection filled with the returned values of `fn`.

```javascript
map([1,2,3], function(item){
map([1,2,3], function(item){
return item * 2

@@ -77,3 +77,3 @@ }) // [2,4,6]

### `pluck(collection, property)` -> `new collection`
### pluck(collection, property) > new collection

@@ -86,3 +86,3 @@ Return a collection filled with `item[property]` or `null` for each `item` in `collection`

### `reduce(collection, fn[, defaultValue[, thisValue]])` -> `any`
### reduce(collection, fn[, defaultValue[, thisValue]]) > any

@@ -97,5 +97,5 @@ Executes `fn` with `[lastReturnedValue, item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`. Returns `lastReturnedValue`

### `reduceRight(collection, fn[, defaultValue[, thisValue]])` -> `any`
### reduceRight(collection, fn[, defaultValue[, thisValue]]) > any
Executes `fn` with `[lastReturnedValue, item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`. Returns `lastReturnedValue`; like `reduce` but loops from the end to the start.
Executes `fn` with `[lastReturnedValue, item, index, collection]` as arguments (and an optional `thisValue`) for each item in `collection`. Returns `lastReturnedValue`; like `reduce` but loops from the end to the start.

@@ -108,5 +108,5 @@ ```javascript

### `getKeys(collection)` -> `array`
### getKeys(collection) > array
Returns an array filled with `collection`'s keys.
Returns an array filled with `collection`'s keys.

@@ -117,5 +117,5 @@ ```javascript

### `getValues(collection)` -> `array`
### getValues(collection) > array
Returns an array filled with `collection`'s values.
Returns an array filled with `collection`'s values.

@@ -126,5 +126,5 @@ ```javascript

### `getPairs(collection)` -> `array`
### getPairs(collection) > array
Returns an array filled with `collection`'s keys/values pairs.
Returns an array filled with `collection`'s keys/values pairs.

@@ -135,5 +135,5 @@ ```javascript

### `getSize(collection)` -> `number`
### getSize(collection) > number
Returns `collection`'s size (number of values).
Returns `collection`'s size (number of values).

@@ -144,3 +144,3 @@ ```javascript

### `indexOf(array, value)` -> `number`
### indexOf(array, value) > number

@@ -154,3 +154,3 @@ Returns first `value`'s index in `array` or `-1` if not found.

### `lastIndexOf(array, value)` -> `number`
### lastIndexOf(array, value) > number

@@ -165,3 +165,3 @@ Returns first `value`'s index in `array` or `-1` if not found.

### `contains(array, value)` -> `boolean`
### contains(array, value) > boolean

@@ -176,3 +176,3 @@ Returns whether or not `array` contains `value`

### `clone(value[, deep=false])` -> `clonedObject`
### clone(value[, deep=false]) > clonedObject

@@ -186,5 +186,5 @@ Clones `value` (optionaly `deep`).

### `range([start=0,] end[, step=1]) -> array`
### range([start=0,] end[, step=1]) > array
Creates an array filled with values from `start` to `end`, separated with `step`.
Creates an array filled with values from `start` to `end`, separated with `step`.

@@ -200,6 +200,6 @@ ```javascript

### `iterator(array) -> fn`
### iterator(array) > fn
Returns a function that returns the next element in the array every time it is called.
Works with sparse arrays.
Returns a function that returns the next element in the array every time it is called.
Works with sparse arrays.

@@ -217,5 +217,5 @@ ```javascript

### `zip(array1, array2, …) -> array`
### zip(array1, array2, …) > array
Returns a array of arrays containing the values for their index in `array1`, `array2` etc.
Returns a array of arrays containing the values for their index in `array1`, `array2` etc.

@@ -222,0 +222,0 @@ ```javascript

var tape = require("tape")
, clone = require("../lib/clone")
var clone = require("../lib/clone")
tape("clone", function(test){
var array = [1,2,3,4,5]
, object = (function(){
function K(){
this.constructor = "foo"
this.foo = "bar"
}
K.prototype.bar = "baz"
return new K()
})()
, clonedArray = clone(array)
, clonedObject = clone(object)
, deepArray = [1,2, [1,2, {foo:"bar"}], 3]
, deepClonedArray = clone(deepArray, true)
var object = (function(){
function K(){
this.constructor = "foo"
this.foo = "bar"
}
K.prototype.bar = "baz"
return new K()
})()
var clonedArray = clone(array)
var clonedObject = clone(object)
var deepArray = [1,2, [1,2, {foo:"bar"}], 3]
var deepClonedArray = clone(deepArray, true)
test.notEqual(array, clonedArray, "clone(array), reference not equal")
test.deepEqual(array, clonedArray, "clone(array), deep equal")
array[0] = 2
test.equal(clonedArray[0], 1, "clone(array), reference broken")
test.notEqual(object, clonedObject, "clone(object), reference not equal")

@@ -30,12 +30,12 @@ test.equal(clonedObject.foo, "bar", "clone(object), equal")

test.equal(clonedObject.constructor, "foo", "passes through `constructor` property")
object.foo = "baz"
test.equal(clonedObject.foo, "bar", "clone(object), reference broken")
test.deepEqual(deepClonedArray, deepArray, "deep cloning")
test.notEqual(deepClonedArray[2], deepArray[2], "deep cloning, inner array references")
test.notEqual(deepClonedArray[2][2], deepArray[2][2], "deep cloning, inner object references")
test.end()
})
var tape = require("tape")
, contains = require("../lib/contains")
var contains = require("../lib/contains")

@@ -4,0 +4,0 @@ tape("contains", function(test){

var tape = require("tape")
, each = require("../lib/each")
var each = require("../lib/each")
tape("each", function(test){
var object, array, aggregator, lastIndex

@@ -23,3 +23,3 @@ function Obj(){

test.equal(each(array, function(){}), void 0, "Returns undefined")
each([1], function(){

@@ -38,3 +38,3 @@ test.equal(this, Obj, "thisValue is passed with Array")

test.equal(aggregator.join(), "1,0,1,1,,2,1,3", "Iteration on Array is correct")
aggregator.length = 0

@@ -41,0 +41,0 @@

var tape = require("tape")
, extend = require("../lib/extend")
var extend = require("../lib/extend")

@@ -4,0 +4,0 @@ tape("extend", function(test){

var tape = require("tape")
, filter = require("../lib/filter")
var filter = require("../lib/filter")
tape("filter", function (test) {
var object, array, aggregator, lastIndex
var object
var array
var aggregator
var lastIndex
function Obj() {

@@ -9,0 +12,0 @@ this.foo = 1

var tape = require("tape")
, getKeys = require("../lib/getKeys")
var getKeys = require("../lib/getKeys")
tape("getKeys", function(test){
var object, array
var object
var array

@@ -13,3 +14,3 @@ function Obj(){

}
Obj.prototype.baz = "foo"

@@ -19,3 +20,3 @@

array = [1,1]
array[3] = 1

@@ -22,0 +23,0 @@

var tape = require("tape")
, getPairs = require("../lib/getPairs")
var getPairs = require("../lib/getPairs")
tape("getPairs", function(test){
var object, array
var object
var array

@@ -26,2 +27,2 @@ function Obj(){

})
})
var tape = require("tape")
, getSize = require("../lib/getSize")
var getSize = require("../lib/getSize")

@@ -19,4 +19,4 @@ tape("getSize", function(test){

test.equal(getSize([1,2,3]) , 3, "Arrays")
test.end()
})
var tape = require("tape")
, getValues = require("../lib/getValues")
var getValues = require("../lib/getValues")
tape("getValues", function(test){
var object, array
var object
var array
function Obj(){

@@ -26,2 +27,2 @@ this.foo = "bar"

})
})
var tape = require("tape")
, indexOf = require("../lib/indexOf")
var indexOf = require("../lib/indexOf")

@@ -4,0 +4,0 @@ tape("indexOf", function(test){

var tape = require("tape")
, isArrayLike = require("../lib/isArrayLike")
var isArrayLike = require("../lib/isArrayLike")
tape("isArrayLike", function(test){
test.equal(isArrayLike([]), true, "Array")
test.equal(isArrayLike((function(){return arguments})()), true, "Arguments")
test.equal(isArrayLike({0:1,length:1}), true, "Objects")
test.end()
})
var tape = require("tape")
, iterator = require("../lib/iterator")
var iterator = require("../lib/iterator")
tape("iterator", function(test){
var array = Array(5)
, i = iterator(array)
var i = iterator(array)
array.push(1, 2, 3, 4)
test.equal(i(), 1, "ignores not defined properties; uses array ref")

@@ -17,3 +17,3 @@ test.equal(i(), 2)

test.end()
})
var tape = require("tape")
, indexOf = require("../lib/lastIndexOf")
var indexOf = require("../lib/lastIndexOf")

@@ -4,0 +4,0 @@ tape("lastIndexOf", function(test){

var tape = require("tape")
, map = require("../lib/map")
var map = require("../lib/map")
tape("map", function(test){
var object, array, aggregator, lastIndex
var object
var array
var aggregator
var lastIndex
function Obj(){

@@ -35,4 +38,4 @@ this.foo = 1

test.deepEqual(map(object, function(a){return a * a}), {"foo":1, "bar":4, constructor:9}, "with Object")
test.end()
})
var tape = require("tape")
, pluck = require("../lib/pluck")
var pluck = require("../lib/pluck")
tape("pluck", function(test){
var object, array, aggregator, lastIndex
var object
var array
var aggregator
var lastIndex
function Obj(){

@@ -26,4 +29,4 @@ this.foo = {foo:1}

test.deepEqual(pluck(object, "foo"), {"foo":1, "bar":2, "constructor":3}, "Maps on Object")
test.end()
})
var tape = require("tape")
, range = require("../lib/range")
var range = require("../lib/range")
tape("range", function(test){
test.deepEqual(range(0), [])

@@ -15,3 +15,3 @@ test.deepEqual(range(5), [0,1,2,3,4])

test.end()
})
var tape = require("tape")
, reduce = require("../lib/reduce")
var reduce = require("../lib/reduce")
tape("reduce", function(test){
var object, array, aggregator, lastIndex
var object
var array
var aggregator
var lastIndex
function Obj() {

@@ -12,5 +15,5 @@ this.foo = 1

}
Obj.prototype.baz = 4
object = new Obj

@@ -20,3 +23,3 @@ array = [1, 2]

lastIndex
array[3] = 3

@@ -73,4 +76,4 @@

)
test.end()
})
var tape = require("tape")
, reduceRight = require("../lib/reduceRight")
var reduceRight = require("../lib/reduceRight")
tape("reduceRight", function(test){
var object, array, aggregator, lastIndex
var object
var array
var aggregator
var lastIndex
function Obj() {

@@ -12,5 +15,5 @@ this.foo = 1

}
Obj.prototype.baz = 4
object = new Obj

@@ -20,3 +23,3 @@ array = [1, 2]

lastIndex
array[3] = 3

@@ -26,11 +29,11 @@ test.equal(reduceRight(void 0, function(){}), null, "Ignores falsy values")

test.deepEqual(
reduceRight(array, function(a,b){return a + (b == null ? "" : "" + b)}, "4")
, "4321"
, "Reduce on Arrays"
reduceRight(array, function(a,b){return a + (b == null ? "" : "" + b)}, "4"),
"4321",
"Reduce on Arrays"
)
test.deepEqual(
reduceRight(array, function(a,b){return a + (b == null ? "" : "" + b)})
, "321"
, "Reduce on Arrays without initial value"
reduceRight(array, function(a,b){return a + (b == null ? "" : "" + b)}),
"321",
"Reduce on Arrays without initial value"
)

@@ -40,5 +43,5 @@

test.equal(
this
, Obj
, "thisValue is passed with Array"
this,
Obj,
"thisValue is passed with Array"
)

@@ -49,5 +52,5 @@ }, 0, Obj)

test.equal(
this
, Obj
, "thisValue is passed with Object"
this,
Obj,
"thisValue is passed with Object"
)

@@ -57,19 +60,19 @@ }, 0, Obj)

test.equal(
reduceRight(object, function(a,b){return a + (b == null ? "" : "" + b)}, "4")
, "4321"
, "Reduce on Object"
reduceRight(object, function(a,b){return a + (b == null ? "" : "" + b)}, "4"),
"4321",
"Reduce on Object"
)
test.equal(
reduceRight(object, function(a,b){return a + (b == null ? "" : "" + b)})
, "321"
, "Reduce on Object without inital value"
reduceRight(object, function(a,b){return a + (b == null ? "" : "" + b)}),
"321",
"Reduce on Object without inital value"
)
test.equal(
reduceRight([""], function(a,b){return a + b}, void 0)
, "undefined"
, "Authorizes undefined as initialValue"
reduceRight([""], function(a,b){return a + b}, void 0),
"undefined",
"Authorizes undefined as initialValue"
)
test.end()
})
})
var tape = require("tape")
, reject = require("../lib/reject")
var reject = require("../lib/reject")
tape("reject", function (test) {
var object, array, aggregator, lastIndex
var object
var array
var aggregator
var lastIndex

@@ -46,4 +49,4 @@ function Obj() {

)
test.end()
})
var tape = require("tape")
, zip = require("../lib/zip")
var zip = require("../lib/zip")
tape("zip", function(test){
test.deepEqual(

@@ -10,3 +10,3 @@ zip(["foo", "bar"], [1, 2], [true, false]),

)
test.deepEqual(

@@ -17,4 +17,4 @@ zip(["foo", 1, true], ["bar", 2, false]),

)
test.equal(

@@ -21,0 +21,0 @@ zip(["foo", "bar", "baz"], [1, 2, 3], [true, false])[2][2],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc