aboutsummaryrefslogtreecommitdiff
path: root/node_modules/object-keys
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-10 03:43:44 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-10 03:43:44 +0200
commitabd94a7f5a50f43c797a11b53549ae48fff667c3 (patch)
treeab8ed457f65cdd72e13e0571d2975729428f1551 /node_modules/object-keys
parenta0247c6a3fd6a09a41a7e35a3441324c4dcb58be (diff)
add node_modules to address #4364
Diffstat (limited to 'node_modules/object-keys')
-rw-r--r--node_modules/object-keys/.npmignore1
-rw-r--r--node_modules/object-keys/.travis.yml5
-rw-r--r--node_modules/object-keys/README.md39
-rw-r--r--node_modules/object-keys/foreach.js40
-rw-r--r--node_modules/object-keys/index.js2
-rw-r--r--node_modules/object-keys/isArguments.js16
-rw-r--r--node_modules/object-keys/package.json108
-rw-r--r--node_modules/object-keys/shim.js62
-rw-r--r--node_modules/object-keys/test/foreach.js156
-rw-r--r--node_modules/object-keys/test/index.js6
-rw-r--r--node_modules/object-keys/test/isArguments.js10
-rw-r--r--node_modules/object-keys/test/shim.js134
12 files changed, 579 insertions, 0 deletions
diff --git a/node_modules/object-keys/.npmignore b/node_modules/object-keys/.npmignore
new file mode 100644
index 000000000..3c3629e64
--- /dev/null
+++ b/node_modules/object-keys/.npmignore
@@ -0,0 +1 @@
+node_modules
diff --git a/node_modules/object-keys/.travis.yml b/node_modules/object-keys/.travis.yml
new file mode 100644
index 000000000..60d00ce14
--- /dev/null
+++ b/node_modules/object-keys/.travis.yml
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - "0.10"
+ - "0.8"
+ - "0.6"
diff --git a/node_modules/object-keys/README.md b/node_modules/object-keys/README.md
new file mode 100644
index 000000000..ab32d0ad0
--- /dev/null
+++ b/node_modules/object-keys/README.md
@@ -0,0 +1,39 @@
+#object-keys <sup>[![Version Badge][2]][1]</sup>
+
+[![Build Status][3]][4] [![dependency status][5]][6]
+
+[![browser support][7]][8]
+
+An Object.keys shim. Uses Object.keys if available.
+
+## Example
+
+```js
+var keys = require('object-keys');
+var assert = require('assert');
+var obj = {
+ a: true,
+ b: true,
+ c: true
+};
+
+assert.equal(keys(obj), ['a', 'b', 'c']);
+```
+
+## Source
+Implementation taken directly from [es5-shim]([9]), with modifications, including from [lodash]([10]).
+
+## Tests
+Simply clone the repo, `npm install`, and run `npm test`
+
+[1]: https://npmjs.org/package/object-keys
+[2]: http://vb.teelaun.ch/ljharb/object-keys.svg
+[3]: https://travis-ci.org/ljharb/object-keys.png
+[4]: https://travis-ci.org/ljharb/object-keys
+[5]: https://david-dm.org/ljharb/object-keys.png
+[6]: https://david-dm.org/ljharb/object-keys
+[7]: https://ci.testling.com/ljharb/object-keys.png
+[8]: https://ci.testling.com/ljharb/object-keys
+[9]: https://github.com/kriskowal/es5-shim/blob/master/es5-shim.js#L542-589
+[10]: https://github.com/bestiejs/lodash
+
diff --git a/node_modules/object-keys/foreach.js b/node_modules/object-keys/foreach.js
new file mode 100644
index 000000000..db32d4582
--- /dev/null
+++ b/node_modules/object-keys/foreach.js
@@ -0,0 +1,40 @@
+var hasOwn = Object.prototype.hasOwnProperty;
+var toString = Object.prototype.toString;
+
+var isFunction = function (fn) {
+ var isFunc = (typeof fn === 'function' && !(fn instanceof RegExp)) || toString.call(fn) === '[object Function]';
+ if (!isFunc && typeof window !== 'undefined') {
+ isFunc = fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt;
+ }
+ return isFunc;
+};
+
+module.exports = function forEach(obj, fn) {
+ if (!isFunction(fn)) {
+ throw new TypeError('iterator must be a function');
+ }
+ var i, k,
+ isString = typeof obj === 'string',
+ l = obj.length,
+ context = arguments.length > 2 ? arguments[2] : null;
+ if (l === +l) {
+ for (i = 0; i < l; i++) {
+ if (context === null) {
+ fn(isString ? obj.charAt(i) : obj[i], i, obj);
+ } else {
+ fn.call(context, isString ? obj.charAt(i) : obj[i], i, obj);
+ }
+ }
+ } else {
+ for (k in obj) {
+ if (hasOwn.call(obj, k)) {
+ if (context === null) {
+ fn(obj[k], k, obj);
+ } else {
+ fn.call(context, obj[k], k, obj);
+ }
+ }
+ }
+ }
+};
+
diff --git a/node_modules/object-keys/index.js b/node_modules/object-keys/index.js
new file mode 100644
index 000000000..f5b24b6d7
--- /dev/null
+++ b/node_modules/object-keys/index.js
@@ -0,0 +1,2 @@
+module.exports = Object.keys || require('./shim');
+
diff --git a/node_modules/object-keys/isArguments.js b/node_modules/object-keys/isArguments.js
new file mode 100644
index 000000000..74a098978
--- /dev/null
+++ b/node_modules/object-keys/isArguments.js
@@ -0,0 +1,16 @@
+var toString = Object.prototype.toString;
+
+module.exports = function isArguments(value) {
+ var str = toString.call(value);
+ var isArguments = str === '[object Arguments]';
+ if (!isArguments) {
+ isArguments = str !== '[object Array]'
+ && value !== null
+ && typeof value === 'object'
+ && typeof value.length === 'number'
+ && value.length >= 0
+ && toString.call(value.callee) === '[object Function]';
+ }
+ return isArguments;
+};
+
diff --git a/node_modules/object-keys/package.json b/node_modules/object-keys/package.json
new file mode 100644
index 000000000..4ecf3ff21
--- /dev/null
+++ b/node_modules/object-keys/package.json
@@ -0,0 +1,108 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "object-keys@~0.4.0",
+ "scope": null,
+ "escapedName": "object-keys",
+ "name": "object-keys",
+ "rawSpec": "~0.4.0",
+ "spec": ">=0.4.0 <0.5.0",
+ "type": "range"
+ },
+ "/home/dold/repos/taler/wallet-webex/node_modules/gulp-gzip/node_modules/through2/node_modules/xtend"
+ ]
+ ],
+ "_from": "object-keys@>=0.4.0 <0.5.0",
+ "_id": "object-keys@0.4.0",
+ "_inCache": true,
+ "_location": "/object-keys",
+ "_npmUser": {
+ "name": "ljharb",
+ "email": "ljharb@gmail.com"
+ },
+ "_npmVersion": "1.3.5",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "object-keys@~0.4.0",
+ "scope": null,
+ "escapedName": "object-keys",
+ "name": "object-keys",
+ "rawSpec": "~0.4.0",
+ "spec": ">=0.4.0 <0.5.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/gulp-gzip/through2/xtend",
+ "/gulp-stream/xtend"
+ ],
+ "_resolved": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz",
+ "_shasum": "28a6aae7428dd2c3a92f3d95f21335dd204e0336",
+ "_shrinkwrap": null,
+ "_spec": "object-keys@~0.4.0",
+ "_where": "/home/dold/repos/taler/wallet-webex/node_modules/gulp-gzip/node_modules/through2/node_modules/xtend",
+ "author": {
+ "name": "Jordan Harband"
+ },
+ "bugs": {
+ "url": "https://github.com/ljharb/object-keys/issues"
+ },
+ "dependencies": {},
+ "deprecated": "",
+ "description": "An Object.keys replacement, in case Object.keys is not available. From https://github.com/kriskowal/es5-shim",
+ "devDependencies": {
+ "foreach": "~2.0.3",
+ "indexof": "~0.0.1",
+ "is": "~0.2.6",
+ "tape": "~1.0.4"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "28a6aae7428dd2c3a92f3d95f21335dd204e0336",
+ "tarball": "https://registry.npmjs.org/object-keys/-/object-keys-0.4.0.tgz"
+ },
+ "homepage": "https://github.com/ljharb/object-keys#readme",
+ "keywords": [
+ "Object.keys",
+ "keys",
+ "ES5",
+ "shim"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "ljharb",
+ "email": "ljharb@gmail.com"
+ }
+ ],
+ "name": "object-keys",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/ljharb/object-keys.git"
+ },
+ "scripts": {
+ "test": "node test/index.js"
+ },
+ "testling": {
+ "files": "test/index.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.4.0"
+}
diff --git a/node_modules/object-keys/shim.js b/node_modules/object-keys/shim.js
new file mode 100644
index 000000000..b88421bed
--- /dev/null
+++ b/node_modules/object-keys/shim.js
@@ -0,0 +1,62 @@
+(function () {
+ "use strict";
+
+ // modified from https://github.com/kriskowal/es5-shim
+ var has = Object.prototype.hasOwnProperty,
+ toString = Object.prototype.toString,
+ forEach = require('./foreach'),
+ isArgs = require('./isArguments'),
+ hasDontEnumBug = !({'toString': null}).propertyIsEnumerable('toString'),
+ hasProtoEnumBug = (function () {}).propertyIsEnumerable('prototype'),
+ dontEnums = [
+ "toString",
+ "toLocaleString",
+ "valueOf",
+ "hasOwnProperty",
+ "isPrototypeOf",
+ "propertyIsEnumerable",
+ "constructor"
+ ],
+ keysShim;
+
+ keysShim = function keys(object) {
+ var isObject = object !== null && typeof object === 'object',
+ isFunction = toString.call(object) === '[object Function]',
+ isArguments = isArgs(object),
+ theKeys = [];
+
+ if (!isObject && !isFunction && !isArguments) {
+ throw new TypeError("Object.keys called on a non-object");
+ }
+
+ if (isArguments) {
+ forEach(object, function (value) {
+ theKeys.push(value);
+ });
+ } else {
+ var name,
+ skipProto = hasProtoEnumBug && isFunction;
+
+ for (name in object) {
+ if (!(skipProto && name === 'prototype') && has.call(object, name)) {
+ theKeys.push(name);
+ }
+ }
+ }
+
+ if (hasDontEnumBug) {
+ var ctor = object.constructor,
+ skipConstructor = ctor && ctor.prototype === object;
+
+ forEach(dontEnums, function (dontEnum) {
+ if (!(skipConstructor && dontEnum === 'constructor') && has.call(object, dontEnum)) {
+ theKeys.push(dontEnum);
+ }
+ });
+ }
+ return theKeys;
+ };
+
+ module.exports = keysShim;
+}());
+
diff --git a/node_modules/object-keys/test/foreach.js b/node_modules/object-keys/test/foreach.js
new file mode 100644
index 000000000..f29f065a3
--- /dev/null
+++ b/node_modules/object-keys/test/foreach.js
@@ -0,0 +1,156 @@
+var test = require('tape');
+var forEach = require('../foreach.js');
+
+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 = {};
+ st.plan(arr.length);
+ forEach(arr, 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 = {};
+ st.plan(1);
+ forEach({foo: 'bar'}, 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');
+ });
+ t.end();
+});
+
diff --git a/node_modules/object-keys/test/index.js b/node_modules/object-keys/test/index.js
new file mode 100644
index 000000000..8b77b1fce
--- /dev/null
+++ b/node_modules/object-keys/test/index.js
@@ -0,0 +1,6 @@
+
+require('./foreach');
+require('./isArguments');
+
+require('./shim');
+
diff --git a/node_modules/object-keys/test/isArguments.js b/node_modules/object-keys/test/isArguments.js
new file mode 100644
index 000000000..62a07c2d8
--- /dev/null
+++ b/node_modules/object-keys/test/isArguments.js
@@ -0,0 +1,10 @@
+var test = require('tape');
+var isArguments = require('../isArguments');
+
+test('is.arguments', function (t) {
+ t.notOk(isArguments([]), 'array is not arguments');
+ (function () { t.ok(isArguments(arguments), 'arguments is arguments'); }());
+ (function () { t.notOk(isArguments(Array.prototype.slice.call(arguments)), 'sliced arguments is not arguments'); }());
+ t.end();
+});
+
diff --git a/node_modules/object-keys/test/shim.js b/node_modules/object-keys/test/shim.js
new file mode 100644
index 000000000..9d9327127
--- /dev/null
+++ b/node_modules/object-keys/test/shim.js
@@ -0,0 +1,134 @@
+var test = require('tape');
+var shimmedKeys = require('../index.js');
+var is = require('is');
+var keys = require('../shim.js');
+var forEach = require('foreach');
+var indexOf = require('indexof');
+
+var obj = {
+ "str": "boz",
+ "obj": {},
+ "arr": [],
+ "bool": true,
+ "num": 42,
+ "aNull": null,
+ "undef": undefined
+};
+var objKeys = ['str', 'obj', 'arr', 'bool', 'num', 'aNull', 'undef'];
+
+test('exports a function', function (t) {
+ if (Object.keys) {
+ t.equal(Object.keys, shimmedKeys, 'Object.keys is supported and exported');
+ } else {
+ t.equal(keys, shimmedKeys, 'Object.keys is not supported; shim is exported');
+ }
+ t.end();
+});
+
+test('working with actual shim', function (t) {
+ t.notEqual(Object.keys, keys, 'keys shim is not native Object.keys');
+ t.end();
+});
+
+test('works with an object literal', function (t) {
+ var theKeys = keys(obj);
+ t.equal(is.array(theKeys), true, 'returns an array');
+ t.deepEqual(theKeys, objKeys, 'Object has expected keys');
+ t.end();
+});
+
+test('works with an array', function (t) {
+ var arr = [1, 2, 3];
+ var theKeys = keys(arr);
+ t.equal(is.array(theKeys), true, 'returns an array');
+ t.deepEqual(theKeys, ['0', '1', '2'], 'Array has expected keys');
+ t.end();
+});
+
+test('works with a function', function (t) {
+ var foo = function () {};
+ foo.a = true;
+
+ t.doesNotThrow(function () { return keys(foo); }, 'does not throw an error');
+ t.deepEqual(keys(foo), ['a'], 'returns expected keys');
+ t.end();
+});
+
+test('returns names which are own properties', function (t) {
+ forEach(keys(obj), function (name) {
+ t.equal(obj.hasOwnProperty(name), true, name + ' should be returned');
+ });
+ t.end();
+});
+
+test('returns names which are enumerable', function (t) {
+ var k, loopedValues = [];
+ for (k in obj) {
+ loopedValues.push(k);
+ }
+ forEach(keys(obj), function (name) {
+ t.notEqual(indexOf(loopedValues, name), -1, name + ' is not enumerable');
+ });
+ t.end();
+});
+
+test('throws an error for a non-object', function (t) {
+ t.throws(
+ function () { return keys(42); },
+ new TypeError('Object.keys called on a non-object'),
+ 'throws on a non-object'
+ );
+ t.end();
+});
+
+test('works with an object instance', function (t) {
+ var Prototype = function () {};
+ Prototype.prototype.foo = true;
+ var obj = new Prototype();
+ obj.bar = true;
+ var theKeys = keys(obj);
+ t.equal(is.array(theKeys), true, 'returns an array');
+ t.deepEqual(theKeys, ['bar'], 'Instance has expected keys');
+ t.end();
+});
+
+test('works in iOS 5 mobile Safari', function (t) {
+ var Foo = function () {};
+ Foo.a = function () {};
+
+ // the bug is keys(Foo) => ['a', 'prototype'] instead of ['a']
+ t.deepEqual(keys(Foo), ['a'], 'has expected keys');
+ t.end();
+});
+
+test('works in environments with the dontEnum bug (IE < 9)', function (t) {
+ var Foo = function () {};
+ Foo.prototype.a = function () {};
+
+ // the bug is keys(Foo.prototype) => ['a', 'constructor'] instead of ['a']
+ t.deepEqual(keys(Foo.prototype), ['a'], 'has expected keys');
+ t.end();
+});
+
+test('shadowed properties', function (t) {
+ var shadowedProps = [
+ 'dummyControlProp', /* just to be sure */
+ 'constructor',
+ 'hasOwnProperty',
+ 'isPrototypeOf',
+ 'propertyIsEnumerable',
+ 'toLocaleString',
+ 'toString',
+ 'valueOf'
+ ];
+ shadowedProps.sort();
+ var shadowedObject = {};
+ forEach(shadowedProps, function (value, index) {
+ shadowedObject[value] = index;
+ });
+ var shadowedObjectKeys = keys(shadowedObject);
+ shadowedObjectKeys.sort();
+ t.deepEqual(shadowedObjectKeys, shadowedProps, 'troublesome shadowed properties are keys of object literals');
+ t.end();
+});
+