first commit
This commit is contained in:
3
build/node_modules/for-each/.npmignore
generated
vendored
Normal file
3
build/node_modules/for-each/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
*.log
|
||||
*.err
|
||||
7
build/node_modules/for-each/.travis.yml
generated
vendored
Normal file
7
build/node_modules/for-each/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.4
|
||||
- 0.6
|
||||
- 0.8
|
||||
- "0.10"
|
||||
|
||||
19
build/node_modules/for-each/LICENCE
generated
vendored
Normal file
19
build/node_modules/for-each/LICENCE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2012 Raynos.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
43
build/node_modules/for-each/README.md
generated
vendored
Normal file
43
build/node_modules/for-each/README.md
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# for-each [![build status][1]][2]
|
||||
|
||||
[![browser support][3]][4]
|
||||
|
||||
A better forEach.
|
||||
|
||||
## Example
|
||||
|
||||
Like `Array.prototype.forEach` but works on objects.
|
||||
|
||||
```js
|
||||
var forEach = require("for-each")
|
||||
|
||||
forEach({ key: "value" }, function (value, key, object) {
|
||||
/* code */
|
||||
})
|
||||
```
|
||||
|
||||
As a bonus, it's also a perfectly function shim/polyfill for arrays too!
|
||||
|
||||
```js
|
||||
var forEach = require("for-each")
|
||||
|
||||
forEach([1, 2, 3], function (value, index, array) {
|
||||
/* code */
|
||||
})
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
`npm install for-each`
|
||||
|
||||
## Contributors
|
||||
|
||||
- Raynos
|
||||
|
||||
## MIT Licenced
|
||||
|
||||
[1]: https://secure.travis-ci.org/Raynos/for-each.png
|
||||
[2]: http://travis-ci.org/Raynos/for-each
|
||||
[3]: https://ci.testling.com/Raynos/for-each.png
|
||||
[4]: https://ci.testling.com/Raynos/for-each
|
||||
|
||||
46
build/node_modules/for-each/index.js
generated
vendored
Normal file
46
build/node_modules/for-each/index.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
var isFunction = require('is-function')
|
||||
|
||||
module.exports = forEach
|
||||
|
||||
var toString = Object.prototype.toString
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty
|
||||
|
||||
function forEach(list, iterator, context) {
|
||||
if (!isFunction(iterator)) {
|
||||
throw new TypeError('iterator must be a function')
|
||||
}
|
||||
|
||||
if (arguments.length < 3) {
|
||||
context = this
|
||||
}
|
||||
|
||||
if (toString.call(list) === '[object Array]')
|
||||
forEachArray(list, iterator, context)
|
||||
else if (typeof list === 'string')
|
||||
forEachString(list, iterator, context)
|
||||
else
|
||||
forEachObject(list, iterator, context)
|
||||
}
|
||||
|
||||
function forEachArray(array, iterator, context) {
|
||||
for (var i = 0, len = array.length; i < len; i++) {
|
||||
if (hasOwnProperty.call(array, i)) {
|
||||
iterator.call(context, array[i], i, array)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function forEachString(string, iterator, context) {
|
||||
for (var i = 0, len = string.length; i < len; i++) {
|
||||
// no such thing as a sparse string.
|
||||
iterator.call(context, string.charAt(i), i, string)
|
||||
}
|
||||
}
|
||||
|
||||
function forEachObject(object, iterator, context) {
|
||||
for (var k in object) {
|
||||
if (hasOwnProperty.call(object, k)) {
|
||||
iterator.call(context, object[k], k, object)
|
||||
}
|
||||
}
|
||||
}
|
||||
90
build/node_modules/for-each/package.json
generated
vendored
Normal file
90
build/node_modules/for-each/package.json
generated
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"for-each@0.3.2",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "for-each@0.3.2",
|
||||
"_id": "for-each@0.3.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-LEBFC5NI6X8oEyJZO6lnBLmr1NQ=",
|
||||
"_location": "/for-each",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "for-each@0.3.2",
|
||||
"name": "for-each",
|
||||
"escapedName": "for-each",
|
||||
"rawSpec": "0.3.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.3.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/parse-headers"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.2.tgz",
|
||||
"_spec": "0.3.2",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Raynos",
|
||||
"email": "raynos2@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Raynos/for-each/issues",
|
||||
"email": "raynos2@gmail.com"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Jake Verbaten"
|
||||
},
|
||||
{
|
||||
"name": "Jordan Harband",
|
||||
"url": "https://github.com/ljharb"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"is-function": "~1.0.0"
|
||||
},
|
||||
"description": "A better forEach",
|
||||
"devDependencies": {
|
||||
"tape": "~1.1.0"
|
||||
},
|
||||
"homepage": "https://github.com/Raynos/for-each",
|
||||
"keywords": [],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://github.com/Raynos/for-each/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"main": "index",
|
||||
"name": "for-each",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/Raynos/for-each.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test/test.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/test.js",
|
||||
"browsers": [
|
||||
"iexplore/6.0..latest",
|
||||
"firefox/3.0..6.0",
|
||||
"firefox/15.0..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/4.0..10.0",
|
||||
"chrome/20.0..latest",
|
||||
"chrome/canary",
|
||||
"opera/10.0..latest",
|
||||
"opera/next",
|
||||
"safari/4.0..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2"
|
||||
]
|
||||
},
|
||||
"version": "0.3.2"
|
||||
}
|
||||
180
build/node_modules/for-each/test/test.js
generated
vendored
Normal file
180
build/node_modules/for-each/test/test.js
generated
vendored
Normal file
@@ -0,0 +1,180 @@
|
||||
var test = require("tape")
|
||||
, forEach = require("..")
|
||||
|
||||
test("forEach calls each iterator", function (t) {
|
||||
var count = 0
|
||||
t.plan(4)
|
||||
forEach({ a: 1, b: 2 }, function (value, key) {
|
||||
if (count === 0) {
|
||||
t.equal(value, 1)
|
||||
t.equal(key, "a")
|
||||
} else {
|
||||
t.equal(value, 2)
|
||||
t.equal(key, "b")
|
||||
}
|
||||
count++
|
||||
})
|
||||
})
|
||||
|
||||
test("forEach calls iterator with correct this value", function (t) {
|
||||
var thisValue = {}
|
||||
|
||||
t.plan(1)
|
||||
|
||||
forEach([0], function () {
|
||||
t.equal(this, thisValue)
|
||||
}, thisValue)
|
||||
})
|
||||
|
||||
test('second argument: iterator', function (t) {
|
||||
var arr = []
|
||||
t.throws(function () { forEach(arr) }, TypeError, 'undefined is not a function')
|
||||
t.throws(function () { forEach(arr, null) }, TypeError, 'null is not a function')
|
||||
t.throws(function () { forEach(arr, '') }, TypeError, 'string is not a function')
|
||||
t.throws(function () { forEach(arr, /a/) }, TypeError, 'regex is not a function')
|
||||
t.throws(function () { forEach(arr, true) }, TypeError, 'true is not a function')
|
||||
t.throws(function () { forEach(arr, false) }, TypeError, 'false is not a function')
|
||||
t.throws(function () { forEach(arr, NaN) }, TypeError, 'NaN is not a function')
|
||||
t.throws(function () { forEach(arr, 42) }, TypeError, '42 is not a function')
|
||||
t.doesNotThrow(function () { forEach(arr, function () {}) }, 'function is a function')
|
||||
t.doesNotThrow(function () { forEach(arr, setTimeout) }, 'setTimeout is a function')
|
||||
if (typeof window !== 'undefined') {
|
||||
t.doesNotThrow(function () { forEach(arr, window.alert) }, 'alert is a function')
|
||||
}
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('array', function (t) {
|
||||
var arr = [1, 2, 3]
|
||||
|
||||
t.test('iterates over every item', function (st) {
|
||||
var index = 0
|
||||
forEach(arr, function () { index += 1 })
|
||||
st.equal(index, arr.length, 'iterates ' + arr.length + ' times')
|
||||
st.end()
|
||||
})
|
||||
|
||||
t.test('first iterator argument', function (st) {
|
||||
var index = 0
|
||||
st.plan(arr.length)
|
||||
forEach(arr, function (item) {
|
||||
st.equal(arr[index], item, 'item ' + index + ' is passed as first argument')
|
||||
index += 1
|
||||
})
|
||||
st.end();
|
||||
})
|
||||
|
||||
t.test('second iterator argument', function (st) {
|
||||
var counter = 0
|
||||
st.plan(arr.length)
|
||||
forEach(arr, function (item, index) {
|
||||
st.equal(counter, index, 'index ' + index + ' is passed as second argument')
|
||||
counter += 1
|
||||
})
|
||||
st.end();
|
||||
})
|
||||
|
||||
t.test('third iterator argument', function (st) {
|
||||
st.plan(arr.length)
|
||||
forEach(arr, function (item, index, array) {
|
||||
st.deepEqual(arr, array, 'array is passed as third argument')
|
||||
})
|
||||
st.end();
|
||||
})
|
||||
|
||||
t.test('context argument', function (st) {
|
||||
var context = {}
|
||||
forEach([], function () {
|
||||
st.equal(this, context, '"this" is the passed context')
|
||||
}, context)
|
||||
st.end()
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('object', function (t) {
|
||||
var obj = {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
}
|
||||
var keys = ['a', 'b', 'c']
|
||||
|
||||
var F = function () {
|
||||
this.a = 1
|
||||
this.b = 2
|
||||
}
|
||||
F.prototype.c = 3
|
||||
var fKeys = ['a', 'b']
|
||||
|
||||
t.test('iterates over every object literal key', function (st) {
|
||||
var counter = 0
|
||||
forEach(obj, function () { counter += 1 })
|
||||
st.equal(counter, keys.length, 'iterated ' + counter + ' times')
|
||||
st.end()
|
||||
})
|
||||
|
||||
t.test('iterates only over own keys', function (st) {
|
||||
var counter = 0
|
||||
forEach(new F(), function () { counter += 1 })
|
||||
st.equal(counter, fKeys.length, 'iterated ' + fKeys.length + ' times')
|
||||
st.end()
|
||||
})
|
||||
|
||||
t.test('first iterator argument', function (st) {
|
||||
var index = 0
|
||||
st.plan(keys.length)
|
||||
forEach(obj, function (item) {
|
||||
st.equal(obj[keys[index]], item, 'item at key ' + keys[index] + ' is passed as first argument')
|
||||
index += 1
|
||||
})
|
||||
st.end()
|
||||
})
|
||||
|
||||
t.test('second iterator argument', function (st) {
|
||||
var counter = 0
|
||||
st.plan(keys.length)
|
||||
forEach(obj, function (item, key) {
|
||||
st.equal(keys[counter], key, 'key ' + key + ' is passed as second argument')
|
||||
counter += 1
|
||||
})
|
||||
st.end()
|
||||
})
|
||||
|
||||
t.test('third iterator argument', function (st) {
|
||||
st.plan(keys.length)
|
||||
forEach(obj, function (item, key, object) {
|
||||
st.deepEqual(obj, object, 'object is passed as third argument')
|
||||
})
|
||||
st.end()
|
||||
})
|
||||
|
||||
t.test('context argument', function (st) {
|
||||
var context = {}
|
||||
forEach({}, function () {
|
||||
st.equal(this, context, '"this" is the passed context')
|
||||
}, context)
|
||||
st.end()
|
||||
})
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
test('string', function (t) {
|
||||
var str = 'str'
|
||||
t.test('second iterator argument', function (st) {
|
||||
var counter = 0
|
||||
st.plan(str.length * 2 + 1)
|
||||
forEach(str, function (item, index) {
|
||||
st.equal(counter, index, 'index ' + index + ' is passed as second argument')
|
||||
st.equal(str.charAt(index), item)
|
||||
counter += 1
|
||||
})
|
||||
st.equal(counter, str.length, 'iterates ' + str.length + ' times')
|
||||
st.end()
|
||||
})
|
||||
t.end()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user