From 2b75ac1a3304384c3d3e029c089fa6e6bc76f73d Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Wed, 8 Aug 2018 17:04:00 -0700 Subject: [PATCH 01/17] Fixed ES7 issue --- package.json | 4 ++-- src/Object/index.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 496b996..9ee09ce 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "perfected-prototypes", - "version": "1.6.0", + "version": "1.6.1", "description": "An easy way to extend the built in Javascript prototype chains and make JS fun again", "main": "index.js", "scripts": { "test": "mocha ", - "build": "rm -rf ./lib && cp -r ./src/ ./lib && cp package.json ./lib", + "build": "rm -rf ./lib && cp -r ./src/ ./lib && cp package.json ./lib && cp README.md ./lib", "precommit": "npm run prettier", "prepush": "npm run prettier && npm run linter", "prettier": "node ./node_modules/.bin/prettier --config .prettierrc.json './src/**/*.js' --write", diff --git a/src/Object/index.js b/src/Object/index.js index 0f65944..022ff01 100644 --- a/src/Object/index.js +++ b/src/Object/index.js @@ -1,4 +1,5 @@ const safeD = require('lodash/get'); +const merger = require('lodash/merge'); const { mergeExtension } = require('./../merger'); const newObject = {}; @@ -28,7 +29,7 @@ newObject.isEmpty = function isEmpty() { newObject.merge = function merge(...objs) { let mergedObj = this; objs.forEach(obj => { - mergedObj = { ...mergedObj, ...obj }; + mergedObj = merger(this, obj); }); return mergedObj; }; From f91b154d994ec7d76f6f8dc5daa8be995f35efa3 Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Thu, 9 Aug 2018 13:50:46 -0700 Subject: [PATCH 02/17] Added number functionality and object looping methods --- .eslintrc.json | 14 +++++- README.md | 95 ++++++++++++++++++++++++++++++++++++++- package.json | 7 +-- src/Array/extensions.js | 2 +- src/ArrayModules/index.js | 12 +++++ src/Number/index.js | 29 ++++++++++++ src/Object/index.js | 61 ++++++++++++++++++++----- src/index.js | 1 + test/Number.test.js | 29 ++++++++++++ test/Object.test.js | 49 +++++++++++++++++++- yarn.lock | 34 +++----------- 11 files changed, 288 insertions(+), 45 deletions(-) create mode 100644 src/Number/index.js create mode 100644 test/Number.test.js diff --git a/.eslintrc.json b/.eslintrc.json index 4432d96..94d8169 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,6 +11,18 @@ "indent": 0, "no-tabs": 0, "comma-dangle": 0, - "no-plusplus": 0 + "no-plusplus": 0, + "require-jsdoc": [ + "error", + { + "require": { + "FunctionDeclaration": true, + "MethodDefinition": false, + "ClassDeclaration": false, + "ArrowFunctionExpression": false, + "FunctionExpression": false + } + } + ] } } \ No newline at end of file diff --git a/README.md b/README.md index b85c843..321f36a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,15 @@ Or Yarn: $ yarn add perfected-prototypes ``` +## Testing + +Simply run a `npm install` to add the testing library +Then run: +```bash +$ npm run test + +``` + ## Usage Simply require the module into your NodeJS project, no need to assign it to a variable or anything: @@ -57,17 +66,66 @@ require('perfected-prototypes') const foo = { a: { - b: 1 + b: 1, + c: [1,2,3] } } -foo.try('a.b') +console.log(foo.try('a.b')) // => 1 +console.log(foo.try('a.c[1]')) +// => 2 + console.log(foo.try('a.b.c.d.e.f')) // => undefined ``` + +### *Object.forEach()* +Loop over each key and value returning undefined +``` javascript +const foo = { a: 1, b: 2 } + +foo.forEach((key, val) => { + console.log(key, val) +}) + +// => a 1 +// => b 2 +``` + +### *Object.map()* +Similar to `forEach` But this returns the objects returned at the end of the map function +``` javascript +const foo = { a: 1, b: 2 } + +console.log(foo.map((key, val) => { + key = key + '1' + val = val * 2 + return { [key]: val } + }) +) +// => {a1: 2, b2:4} +``` + + +### *Object.reduce()* +Reduce the values witin an object to summate them +``` javascript +const foo = { a: 1, b: 2, c: 3, d: 4 } + +console.log(foo.reduce((prev, [key, val]) => prev + val, 0)) +// => 10 + +const foo = { a: 1, b: 2, c: 3, d: 4 } + +console.log(foo.reduce((prev, [key, val]) => {prev.push(val); return prev}, [])) +// => [1,2,3,4] +``` + + + ### *Object.isEmpty()* Test to see if there is any values within your object ```javascript @@ -117,6 +175,14 @@ console.log(foo.toArray()) // => [1,2,3] ``` +### *Object.forEach()* +Loop over the key value pair in the object + +```javascript + + +``` + ### *Object.deepCopy()* Deep copy the object with `JSON.parse(JSON.stringify())`, erasing any object references @@ -358,6 +424,31 @@ console.log(str.contains('fox')) ``` +## Number Methods + +### *Number.round()* +Round a number to a decimal place +``` javascript + +const num = 1.23456 + +console.log(num.round()) + +// => 1 + +console.log(num.round(2)) +// => 1.23 +``` + +### *Number.random()* +Generate a random number between the two parameters +```javascript + +console.log(Number.random(0,5)) +// => Between 0-5 +``` + + ## Contributing Please feel free to add an issue, or create a pull request to add extra functionality to the prototype chain. However, I don't want to pollute the chain with the entire library of lodash persay, just the most useful functions. diff --git a/package.json b/package.json index 9ee09ce..15c7bca 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "perfected-prototypes", - "version": "1.6.1", + "version": "1.7.0", "description": "An easy way to extend the built in Javascript prototype chains and make JS fun again", "main": "index.js", "scripts": { - "test": "mocha ", + "test": "./node_modules/.bin/mocha", "build": "rm -rf ./lib && cp -r ./src/ ./lib && cp package.json ./lib && cp README.md ./lib", "precommit": "npm run prettier", "prepush": "npm run prettier && npm run linter", @@ -50,6 +50,7 @@ "prettier": "^1.14.0" }, "dependencies": { + "babel": "^6.23.0", "lodash": "^4.17.10" } -} \ No newline at end of file +} diff --git a/src/Array/extensions.js b/src/Array/extensions.js index 4602ac2..5d63fe0 100644 --- a/src/Array/extensions.js +++ b/src/Array/extensions.js @@ -83,7 +83,7 @@ extensionArray.deepEqual = function deepEqual(arr) { }; /** - * Find all instances of Objects in a Array + * Find all instances of Objects in a Array (Powered by 'filter' in Lodash) * @param {function|object|array|string} selector - Function: A truthy function that specifies what your searching for * @param {Object} selector - Object: The object trying to be matched in the array * @param {Array} selector - Array: The array of values correlating to what is being matched diff --git a/src/ArrayModules/index.js b/src/ArrayModules/index.js index 19f4fc9..e1284af 100644 --- a/src/ArrayModules/index.js +++ b/src/ArrayModules/index.js @@ -1,7 +1,19 @@ +/** + * Look through an array for types of each place + * @param {[*]} arr - The array to be looked at + * @returns {*} - The array of types the array contains + */ function types(arr) { return arr.map(el => typeof el); } +/** + * + * @param {number} low - The lower limit of ranodomization + * @param {number} high - the upper limit of the randomization + * @param {number} size - How long the array should be + * @returns {[number]} - An array of numbers within the given range + */ function rangeArr(low, high, size) { const arr = []; let loopSize = size; diff --git a/src/Number/index.js b/src/Number/index.js new file mode 100644 index 0000000..ea1e52d --- /dev/null +++ b/src/Number/index.js @@ -0,0 +1,29 @@ +const rounder = require('lodash/round'); +const random = require('lodash/random'); + +const { mergeExtension } = require('./../merger'); + +const newNum = {}; +const mainNum = {}; + +/** + * Round a number to a whole integer or specify decimal places. + * @param {integer} decimal - The decimal place to round to + * @return {number} + */ +newNum.round = function round(decimal = 0) { + return rounder(this, decimal); +}; + +/** + * Create a random number + * @param {number} start - The number value to start from + * @param {number} stop - The number value to stop at + * @return {number} + */ +mainNum.random = function randomGen(start, stop) { + return random(start, stop); +}; + +mergeExtension(Number, mainNum); +mergeExtension(Number.prototype, newNum); diff --git a/src/Object/index.js b/src/Object/index.js index 022ff01..f1934db 100644 --- a/src/Object/index.js +++ b/src/Object/index.js @@ -1,5 +1,6 @@ const safeD = require('lodash/get'); const merger = require('lodash/merge'); + const { mergeExtension } = require('./../merger'); const newObject = {}; @@ -10,7 +11,7 @@ const newObject = {}; * @returns {*|undefined} The value being referenced OR undefined */ newObject.try = function safe(dereference) { - return safeD(this, dereference, undefined); + return safeD(this, dereference, undefined); }; /** @@ -18,7 +19,7 @@ newObject.try = function safe(dereference) { * @returns {boolean} */ newObject.isEmpty = function isEmpty() { - return Object.keys(this).length === 0; + return Object.keys(this).length === 0; }; /** @@ -27,11 +28,11 @@ newObject.isEmpty = function isEmpty() { * @returns {object} The new object merged together from the list of sources */ newObject.merge = function merge(...objs) { - let mergedObj = this; - objs.forEach(obj => { - mergedObj = merger(this, obj); - }); - return mergedObj; + let mergedObj = this; + objs.forEach(obj => { + mergedObj = merger(this, obj); + }); + return mergedObj; }; /** @@ -39,7 +40,7 @@ newObject.merge = function merge(...objs) { * @returns {[*]} - The values of the existing object */ newObject.toArray = function toArray() { - return Object.values(this); + return Object.values(this); }; /** @@ -48,7 +49,7 @@ newObject.toArray = function toArray() { * @returns {Object} - The new object with no references to the original */ newObject.deepCopy = function deepCopy() { - return JSON.parse(JSON.stringify(this)); + return JSON.parse(JSON.stringify(this)); }; /** @@ -58,7 +59,47 @@ newObject.deepCopy = function deepCopy() { */ newObject.deepEqual = function deepEqual(obj) { - return JSON.stringify(this) === JSON.stringify(obj); + return JSON.stringify(this) === JSON.stringify(obj); +}; + +/** + * Loop over each key and value, returning a new object + * @callback func + * @param {string} key - the key in the object + * @param {*} val - the value associated with the key + * @returns {*} obj - The object returned from modification + */ +newObject.map = function map(func) { + return Object.entries(this).reduce( + (prev, [key, val]) => merger(prev, func(key, val)), + {} + ); +}; + +/** + * Loop over each key and value returning undefined + * @callback func + * @param {string} key - the key in the object + * @param {*} val - the value associated with the key + * @returns {undefined} + */ +newObject.forEach = function forEach(func) { + Object.entries(this).map(([key, val]) => func(key, val)); + return undefined; +}; + +/** + * Reduce through the object and return the selected value + * @callback func + * @param {object} accumulator - The object to accumulate values + * @param {object} cur - the current value being iterated + * @returns {*} The value accumulated + */ +newObject.reduce = function reduce(func, accumulator) { + return Object.entries(this).reduce( + (prev, [key, val]) => func(prev, [key, val]), + accumulator + ); }; mergeExtension(Object.prototype, newObject); diff --git a/src/index.js b/src/index.js index 0d41fea..b61ca25 100644 --- a/src/index.js +++ b/src/index.js @@ -1,3 +1,4 @@ require('./Array/index'); require('./Object/index'); require('./String/index'); +require('./Number/index'); diff --git a/test/Number.test.js b/test/Number.test.js new file mode 100644 index 0000000..447a03b --- /dev/null +++ b/test/Number.test.js @@ -0,0 +1,29 @@ +const { assert, expect } = require('chai') +require('./../src/Number/index') + +describe('Number prototype chain', () => { + + describe('Number round prototype', () => { + it('should give back a whole number', () => { + const num = 3.46583123 + assert.equal(3, num.round()) + }) + + it('should round to one decimal place', () => { + const num = 3.46583123 + assert.equal(3.5, num.round(1)) + }) + + it('should round to second decimal place', () => { + const num = 3.46583123 + assert.equal(3.47, num.round(2)) + }) + }) + + describe('Number Random prototype', () => { + it('should generate a number between 0 and 5', () => { + expect(Number.random(0, 5)).to.be.gte(0) + expect(Number.random(0, 5)).to.be.lte(5) + }) + }) +}) \ No newline at end of file diff --git a/test/Object.test.js b/test/Object.test.js index 4068732..d884b71 100644 --- a/test/Object.test.js +++ b/test/Object.test.js @@ -23,6 +23,11 @@ describe('Object prototypes', () => { const obj = { foo: { bar: 1 } } assert.equal(1, obj.try('foo["bar"]')) }) + + it('should be able to access array values in a nested obj', () => { + const obj = { a: { b: [1, 2, 3] } } + assert.equal(1, obj.try('a.b[0]')) + }) }); describe('isEmpty object method', () => { @@ -53,6 +58,48 @@ describe('Object prototypes', () => { }) }) + describe('Object map prototype', () => { + it('should return the mutated object', () => { + const foo = { a: 1, b: 2 } + let res = foo.map((key, val) => { + key = key + '1' + val = val * 2 + return { [key]: val } + }) + assert.deepEqual(res, { a1: 2, b1: 4 }) + }) + }) + + describe('Object forEach prototype', () => { + it('should match the key value pairs appropriately', () => { + const foo = { a: 1, b: 2 } + foo.forEach((key, val) => { + assert.equal(foo[key], val) + }) + }) + }) + + describe('Object reduce prototype', () => { + it('should reduce the values and summate the total of 10', () => { + const foo = { a: 1, b: 2, c: 3, d: 4 } + assert.equal(10, foo.reduce((prev, [key, val]) => prev + val, 0)) + }) + + it('should reduce the values and create a string', () => { + const foo = { a: 'brandon ', b: 'dring ', c: 'rules' } + assert.equal('brandon dring rules', foo.reduce((prev, [key, val]) => prev + val, '')) + }) + + it('should reduce the values and create an array', () => { + const foo = { a: 1, b: 2, c: 3, d: 4 } + assert.deepEqual([1, 2, 3, 4], foo.reduce((prev, [key, val]) => { + prev.push(val) + return prev + }, [])) + }) + }) + + describe('toArray object method', () => { it('should extract all the values from an object and return it as an array ', () => { const obj = { @@ -91,7 +138,7 @@ describe('Object prototypes', () => { }) it('should find that the two objects are NOT equal', () => { - const obj1 = { a: 1, b: true} + const obj1 = { a: 1, b: true } const obj2 = { a: 1, b: true, c: 'bar' } assert.deepEqual(obj1.deepEqual(obj2), false) diff --git a/yarn.lock b/yarn.lock index 9e6f452..f0f57a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -139,6 +139,10 @@ babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.2" +babel@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel/-/babel-6.23.0.tgz#d0d1e7d803e974765beea3232d4e153c0efb90f4" + balanced-match@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -258,7 +262,7 @@ chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1: +chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0: version "2.4.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/chalk/-/chalk-2.4.1.tgz#18c49ab16a037b6eb0152cc83e3471338215b66e" dependencies: @@ -1364,37 +1368,13 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" -lodash.camelcase@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" - lodash.debounce@^4.0.8: version "4.0.8" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af" -lodash.filter@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" - -lodash.find@^4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.find/-/lodash.find-4.6.0.tgz#cb0704d47ab71789ffa0de8b97dd926fb88b13b1" - -lodash.get@^4.4.2: - version "4.4.2" - resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" - -lodash.pull@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/lodash.pull/-/lodash.pull-4.1.0.tgz#60060cc6bd625b4d4567ec27dc45cd1be9eec012" - -lodash.startcase@^4.4.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.startcase/-/lodash.startcase-4.4.0.tgz#9436e34ed26093ed7ffae1936144350915d9add8" - -lodash@^4.17.4, lodash@^4.3.0: +lodash@^4.17.10, lodash@^4.17.4, lodash@^4.3.0: version "4.17.10" - resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" lowercase-keys@^1.0.0: version "1.0.1" From 89f80c26568f71aa0ee18a1f0225713e198ca2a9 Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Thu, 9 Aug 2018 14:05:08 -0700 Subject: [PATCH 03/17] Babel'd the project tested on front and backend --- .babelrc | 5 + README.md | 9 +- package.json | 11 +- src/Object/index.js | 42 +-- test.js | 4 - test/Object.test.js | 2 +- yarn.lock | 850 +++++++++++++++++++++++++++++++++++++++++++- 7 files changed, 877 insertions(+), 46 deletions(-) create mode 100644 .babelrc delete mode 100644 test.js diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..534ac73 --- /dev/null +++ b/.babelrc @@ -0,0 +1,5 @@ +{ + "presets": [ + "env" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 321f36a..d4b36c3 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ An extension to the Javascript Object, Array, and String prototype chain. Extend - Well tested - Easy to install - JSdoc documentated -- Works both in ES6 and Node.JS +- Works both in ES5 & up, and Node.JS - Uses `Object.defineProperty` to avoid pollution of chain methods - Checks to make sure there isn't overwritten methods @@ -33,7 +33,6 @@ Simply run a `npm install` to add the testing library Then run: ```bash $ npm run test - ``` ## Usage @@ -95,12 +94,12 @@ foo.forEach((key, val) => { // => b 2 ``` -### *Object.map()* -Similar to `forEach` But this returns the objects returned at the end of the map function +### *Object.mapOver()* +Similar to `forEach` But this returns the objects returned at the end of the mapOver function ``` javascript const foo = { a: 1, b: 2 } -console.log(foo.map((key, val) => { +console.log(foo.mapOver((key, val) => { key = key + '1' val = val * 2 return { [key]: val } diff --git a/package.json b/package.json index 15c7bca..57fcb09 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "perfected-prototypes", - "version": "1.7.0", + "version": "1.8.0", "description": "An easy way to extend the built in Javascript prototype chains and make JS fun again", "main": "index.js", "scripts": { - "test": "./node_modules/.bin/mocha", - "build": "rm -rf ./lib && cp -r ./src/ ./lib && cp package.json ./lib && cp README.md ./lib", + "test": "./node_modules/.bin/mocha --require babel-register", + "build": "rm -rf ./lib && ./node_modules/.bin/babel src -d lib && cp package.json ./lib && cp README.md ./lib", "precommit": "npm run prettier", "prepush": "npm run prettier && npm run linter", "prettier": "node ./node_modules/.bin/prettier --config .prettierrc.json './src/**/*.js' --write", @@ -38,6 +38,8 @@ }, "homepage": "https://github.com/El-Dringo-Brannde/Perfected-Prototypes#readme", "devDependencies": { + "babel-cli": "^6.26.0", + "babel-preset-env": "^1.7.0", "chai": "^4.1.2", "eslint": "^4.19.1", "eslint-config-airbnb-base": "^13.0.0", @@ -50,7 +52,6 @@ "prettier": "^1.14.0" }, "dependencies": { - "babel": "^6.23.0", "lodash": "^4.17.10" } -} +} \ No newline at end of file diff --git a/src/Object/index.js b/src/Object/index.js index f1934db..450314e 100644 --- a/src/Object/index.js +++ b/src/Object/index.js @@ -11,7 +11,7 @@ const newObject = {}; * @returns {*|undefined} The value being referenced OR undefined */ newObject.try = function safe(dereference) { - return safeD(this, dereference, undefined); + return safeD(this, dereference, undefined); }; /** @@ -19,7 +19,7 @@ newObject.try = function safe(dereference) { * @returns {boolean} */ newObject.isEmpty = function isEmpty() { - return Object.keys(this).length === 0; + return Object.keys(this).length === 0; }; /** @@ -28,11 +28,11 @@ newObject.isEmpty = function isEmpty() { * @returns {object} The new object merged together from the list of sources */ newObject.merge = function merge(...objs) { - let mergedObj = this; - objs.forEach(obj => { - mergedObj = merger(this, obj); - }); - return mergedObj; + let mergedObj = this; + objs.forEach(obj => { + mergedObj = merger(this, obj); + }); + return mergedObj; }; /** @@ -40,7 +40,7 @@ newObject.merge = function merge(...objs) { * @returns {[*]} - The values of the existing object */ newObject.toArray = function toArray() { - return Object.values(this); + return Object.values(this); }; /** @@ -49,7 +49,7 @@ newObject.toArray = function toArray() { * @returns {Object} - The new object with no references to the original */ newObject.deepCopy = function deepCopy() { - return JSON.parse(JSON.stringify(this)); + return JSON.parse(JSON.stringify(this)); }; /** @@ -59,7 +59,7 @@ newObject.deepCopy = function deepCopy() { */ newObject.deepEqual = function deepEqual(obj) { - return JSON.stringify(this) === JSON.stringify(obj); + return JSON.stringify(this) === JSON.stringify(obj); }; /** @@ -69,11 +69,11 @@ newObject.deepEqual = function deepEqual(obj) { * @param {*} val - the value associated with the key * @returns {*} obj - The object returned from modification */ -newObject.map = function map(func) { - return Object.entries(this).reduce( - (prev, [key, val]) => merger(prev, func(key, val)), - {} - ); +newObject.mapOver = function map(func) { + return Object.entries(this).reduce( + (prev, [key, val]) => merger(prev, func(key, val)), + {} + ); }; /** @@ -84,8 +84,8 @@ newObject.map = function map(func) { * @returns {undefined} */ newObject.forEach = function forEach(func) { - Object.entries(this).map(([key, val]) => func(key, val)); - return undefined; + Object.entries(this).map(([key, val]) => func(key, val)); + return undefined; }; /** @@ -96,10 +96,10 @@ newObject.forEach = function forEach(func) { * @returns {*} The value accumulated */ newObject.reduce = function reduce(func, accumulator) { - return Object.entries(this).reduce( - (prev, [key, val]) => func(prev, [key, val]), - accumulator - ); + return Object.entries(this).reduce( + (prev, [key, val]) => func(prev, [key, val]), + accumulator + ); }; mergeExtension(Object.prototype, newObject); diff --git a/test.js b/test.js deleted file mode 100644 index 4112e71..0000000 --- a/test.js +++ /dev/null @@ -1,4 +0,0 @@ -require('./lib/index') - -let f = { a: { b: 2 } } -console.log(f.get('a.b')) \ No newline at end of file diff --git a/test/Object.test.js b/test/Object.test.js index d884b71..70994c4 100644 --- a/test/Object.test.js +++ b/test/Object.test.js @@ -61,7 +61,7 @@ describe('Object prototypes', () => { describe('Object map prototype', () => { it('should return the mutated object', () => { const foo = { a: 1, b: 2 } - let res = foo.map((key, val) => { + let res = foo.mapOver((key, val) => { key = key + '1' val = val * 2 return { [key]: val } diff --git a/yarn.lock b/yarn.lock index f0f57a2..eea43e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -61,6 +61,13 @@ ansi-styles@^3.2.1: dependencies: color-convert "^1.9.0" +anymatch@^1.3.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a" + dependencies: + micromatch "^2.1.5" + normalize-path "^2.0.0" + anymatch@^2.0.0: version "2.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" @@ -85,11 +92,17 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +arr-diff@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf" + dependencies: + arr-flatten "^1.0.1" + arr-diff@^4.0.0: version "4.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" -arr-flatten@^1.1.0: +arr-flatten@^1.0.1, arr-flatten@^1.1.0: version "1.1.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" @@ -107,6 +120,10 @@ array-uniq@^1.0.1: version "1.0.3" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6" +array-unique@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" + array-unique@^0.3.2: version "0.3.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" @@ -131,7 +148,28 @@ atob@^2.1.1: version "2.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/atob/-/atob-2.1.1.tgz#ae2d5a729477f289d60dd7f96a6314a22dd6c22a" -babel-code-frame@^6.22.0: +babel-cli@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" + dependencies: + babel-core "^6.26.0" + babel-polyfill "^6.26.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + commander "^2.11.0" + convert-source-map "^1.5.0" + fs-readdir-recursive "^1.0.0" + glob "^7.1.2" + lodash "^4.17.4" + output-file-sync "^1.1.2" + path-is-absolute "^1.0.1" + slash "^1.0.0" + source-map "^0.5.6" + v8flags "^2.1.1" + optionalDependencies: + chokidar "^1.6.1" + +babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: @@ -139,10 +177,468 @@ babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.2" +babel-core@^6.26.0: + version "6.26.3" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.3.tgz#b2e2f09e342d0f0c88e2f02e067794125e75c207" + dependencies: + babel-code-frame "^6.26.0" + babel-generator "^6.26.0" + babel-helpers "^6.24.1" + babel-messages "^6.23.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + convert-source-map "^1.5.1" + debug "^2.6.9" + json5 "^0.5.1" + lodash "^4.17.4" + minimatch "^3.0.4" + path-is-absolute "^1.0.1" + private "^0.1.8" + slash "^1.0.0" + source-map "^0.5.7" + +babel-generator@^6.26.0: + version "6.26.1" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" + dependencies: + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.17.4" + source-map "^0.5.7" + trim-right "^1.0.1" + +babel-helper-builder-binary-assignment-operator-visitor@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664" + dependencies: + babel-helper-explode-assignable-expression "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-call-delegate@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-call-delegate/-/babel-helper-call-delegate-6.24.1.tgz#ece6aacddc76e41c3461f88bfc575bd0daa2df8d" + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-define-map@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-helper-define-map/-/babel-helper-define-map-6.26.0.tgz#a5f56dab41a25f97ecb498c7ebaca9819f95be5f" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-helper-explode-assignable-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-explode-assignable-expression/-/babel-helper-explode-assignable-expression-6.24.1.tgz#f25b82cf7dc10433c55f70592d5746400ac22caa" + dependencies: + babel-runtime "^6.22.0" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-function-name@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-function-name/-/babel-helper-function-name-6.24.1.tgz#d3475b8c03ed98242a25b48351ab18399d3580a9" + dependencies: + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-get-function-arity@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-get-function-arity/-/babel-helper-get-function-arity-6.24.1.tgz#8f7782aa93407c41d3aa50908f89b031b1b6853d" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-hoist-variables@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-hoist-variables/-/babel-helper-hoist-variables-6.24.1.tgz#1ecb27689c9d25513eadbc9914a73f5408be7a76" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-optimise-call-expression@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-optimise-call-expression/-/babel-helper-optimise-call-expression-6.24.1.tgz#f7a13427ba9f73f8f4fa993c54a97882d1244257" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-helper-regex@^6.24.1: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-helper-regex/-/babel-helper-regex-6.26.0.tgz#325c59f902f82f24b74faceed0363954f6495e72" + dependencies: + babel-runtime "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-helper-remap-async-to-generator@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-remap-async-to-generator/-/babel-helper-remap-async-to-generator-6.24.1.tgz#5ec581827ad723fecdd381f1c928390676e4551b" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helper-replace-supers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helper-replace-supers/-/babel-helper-replace-supers-6.24.1.tgz#bf6dbfe43938d17369a213ca8a8bf74b6a90ab1a" + dependencies: + babel-helper-optimise-call-expression "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-check-es2015-constants@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz#35157b101426fd2ffd3da3f75c7d1e91835bbf8a" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-syntax-async-functions@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" + +babel-plugin-syntax-exponentiation-operator@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" + +babel-plugin-syntax-trailing-function-commas@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-trailing-function-commas/-/babel-plugin-syntax-trailing-function-commas-6.22.0.tgz#ba0360937f8d06e40180a43fe0d5616fff532cf3" + +babel-plugin-transform-async-to-generator@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-async-to-generator/-/babel-plugin-transform-async-to-generator-6.24.1.tgz#6536e378aff6cb1d5517ac0e40eb3e9fc8d08761" + dependencies: + babel-helper-remap-async-to-generator "^6.24.1" + babel-plugin-syntax-async-functions "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-arrow-functions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz#452692cb711d5f79dc7f85e440ce41b9f244d221" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoped-functions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoped-functions/-/babel-plugin-transform-es2015-block-scoped-functions-6.22.0.tgz#bbc51b49f964d70cb8d8e0b94e820246ce3a6141" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-block-scoping@^6.23.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" + dependencies: + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" + +babel-plugin-transform-es2015-classes@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-classes/-/babel-plugin-transform-es2015-classes-6.24.1.tgz#5a4c58a50c9c9461e564b4b2a3bfabc97a2584db" + dependencies: + babel-helper-define-map "^6.24.1" + babel-helper-function-name "^6.24.1" + babel-helper-optimise-call-expression "^6.24.1" + babel-helper-replace-supers "^6.24.1" + babel-messages "^6.23.0" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-computed-properties@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-computed-properties/-/babel-plugin-transform-es2015-computed-properties-6.24.1.tgz#6fe2a8d16895d5634f4cd999b6d3480a308159b3" + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-destructuring@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-destructuring/-/babel-plugin-transform-es2015-destructuring-6.23.0.tgz#997bb1f1ab967f682d2b0876fe358d60e765c56d" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-duplicate-keys@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-duplicate-keys/-/babel-plugin-transform-es2015-duplicate-keys-6.24.1.tgz#73eb3d310ca969e3ef9ec91c53741a6f1576423e" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-for-of@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-for-of/-/babel-plugin-transform-es2015-for-of-6.23.0.tgz#f47c95b2b613df1d3ecc2fdb7573623c75248691" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-function-name@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-function-name/-/babel-plugin-transform-es2015-function-name-6.24.1.tgz#834c89853bc36b1af0f3a4c5dbaa94fd8eacaa8b" + dependencies: + babel-helper-function-name "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-literals@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-literals/-/babel-plugin-transform-es2015-literals-6.22.0.tgz#4f54a02d6cd66cf915280019a31d31925377ca2e" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-modules-amd@^6.22.0, babel-plugin-transform-es2015-modules-amd@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-amd/-/babel-plugin-transform-es2015-modules-amd-6.24.1.tgz#3b3e54017239842d6d19c3011c4bd2f00a00d154" + dependencies: + babel-plugin-transform-es2015-modules-commonjs "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-commonjs@^6.23.0, babel-plugin-transform-es2015-modules-commonjs@^6.24.1: + version "6.26.2" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.2.tgz#58a793863a9e7ca870bdc5a881117ffac27db6f3" + dependencies: + babel-plugin-transform-strict-mode "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" + +babel-plugin-transform-es2015-modules-systemjs@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-systemjs/-/babel-plugin-transform-es2015-modules-systemjs-6.24.1.tgz#ff89a142b9119a906195f5f106ecf305d9407d23" + dependencies: + babel-helper-hoist-variables "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-modules-umd@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-umd/-/babel-plugin-transform-es2015-modules-umd-6.24.1.tgz#ac997e6285cd18ed6176adb607d602344ad38468" + dependencies: + babel-plugin-transform-es2015-modules-amd "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-plugin-transform-es2015-object-super@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-object-super/-/babel-plugin-transform-es2015-object-super-6.24.1.tgz#24cef69ae21cb83a7f8603dad021f572eb278f8d" + dependencies: + babel-helper-replace-supers "^6.24.1" + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-parameters@^6.23.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-parameters/-/babel-plugin-transform-es2015-parameters-6.24.1.tgz#57ac351ab49caf14a97cd13b09f66fdf0a625f2b" + dependencies: + babel-helper-call-delegate "^6.24.1" + babel-helper-get-function-arity "^6.24.1" + babel-runtime "^6.22.0" + babel-template "^6.24.1" + babel-traverse "^6.24.1" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-shorthand-properties@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-shorthand-properties/-/babel-plugin-transform-es2015-shorthand-properties-6.24.1.tgz#24f875d6721c87661bbd99a4622e51f14de38aa0" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-spread@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-spread/-/babel-plugin-transform-es2015-spread-6.22.0.tgz#d6d68a99f89aedc4536c81a542e8dd9f1746f8d1" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-sticky-regex@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-sticky-regex/-/babel-plugin-transform-es2015-sticky-regex-6.24.1.tgz#00c1cdb1aca71112cdf0cf6126c2ed6b457ccdbc" + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-plugin-transform-es2015-template-literals@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-template-literals/-/babel-plugin-transform-es2015-template-literals-6.22.0.tgz#a84b3450f7e9f8f1f6839d6d687da84bb1236d8d" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-typeof-symbol@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz#dec09f1cddff94b52ac73d505c84df59dcceb372" + dependencies: + babel-runtime "^6.22.0" + +babel-plugin-transform-es2015-unicode-regex@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-unicode-regex/-/babel-plugin-transform-es2015-unicode-regex-6.24.1.tgz#d38b12f42ea7323f729387f18a7c5ae1faeb35e9" + dependencies: + babel-helper-regex "^6.24.1" + babel-runtime "^6.22.0" + regexpu-core "^2.0.0" + +babel-plugin-transform-exponentiation-operator@^6.22.0: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-exponentiation-operator/-/babel-plugin-transform-exponentiation-operator-6.24.1.tgz#2ab0c9c7f3098fa48907772bb813fe41e8de3a0e" + dependencies: + babel-helper-builder-binary-assignment-operator-visitor "^6.24.1" + babel-plugin-syntax-exponentiation-operator "^6.8.0" + babel-runtime "^6.22.0" + +babel-plugin-transform-regenerator@^6.22.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz#e0703696fbde27f0a3efcacf8b4dca2f7b3a8f2f" + dependencies: + regenerator-transform "^0.10.0" + +babel-plugin-transform-strict-mode@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-strict-mode/-/babel-plugin-transform-strict-mode-6.24.1.tgz#d5faf7aa578a65bbe591cf5edae04a0c67020758" + dependencies: + babel-runtime "^6.22.0" + babel-types "^6.24.1" + +babel-polyfill@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" + dependencies: + babel-runtime "^6.26.0" + core-js "^2.5.0" + regenerator-runtime "^0.10.5" + +babel-preset-env@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/babel-preset-env/-/babel-preset-env-1.7.0.tgz#dea79fa4ebeb883cd35dab07e260c1c9c04df77a" + dependencies: + babel-plugin-check-es2015-constants "^6.22.0" + babel-plugin-syntax-trailing-function-commas "^6.22.0" + babel-plugin-transform-async-to-generator "^6.22.0" + babel-plugin-transform-es2015-arrow-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoped-functions "^6.22.0" + babel-plugin-transform-es2015-block-scoping "^6.23.0" + babel-plugin-transform-es2015-classes "^6.23.0" + babel-plugin-transform-es2015-computed-properties "^6.22.0" + babel-plugin-transform-es2015-destructuring "^6.23.0" + babel-plugin-transform-es2015-duplicate-keys "^6.22.0" + babel-plugin-transform-es2015-for-of "^6.23.0" + babel-plugin-transform-es2015-function-name "^6.22.0" + babel-plugin-transform-es2015-literals "^6.22.0" + babel-plugin-transform-es2015-modules-amd "^6.22.0" + babel-plugin-transform-es2015-modules-commonjs "^6.23.0" + babel-plugin-transform-es2015-modules-systemjs "^6.23.0" + babel-plugin-transform-es2015-modules-umd "^6.23.0" + babel-plugin-transform-es2015-object-super "^6.22.0" + babel-plugin-transform-es2015-parameters "^6.23.0" + babel-plugin-transform-es2015-shorthand-properties "^6.22.0" + babel-plugin-transform-es2015-spread "^6.22.0" + babel-plugin-transform-es2015-sticky-regex "^6.22.0" + babel-plugin-transform-es2015-template-literals "^6.22.0" + babel-plugin-transform-es2015-typeof-symbol "^6.23.0" + babel-plugin-transform-es2015-unicode-regex "^6.22.0" + babel-plugin-transform-exponentiation-operator "^6.22.0" + babel-plugin-transform-regenerator "^6.22.0" + browserslist "^3.2.6" + invariant "^2.2.2" + semver "^5.3.0" + +babel-register@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" + dependencies: + babel-core "^6.26.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" + home-or-tmp "^2.0.0" + lodash "^4.17.4" + mkdirp "^0.5.1" + source-map-support "^0.4.15" + +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +babel-template@^6.24.1, babel-template@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" + dependencies: + babel-runtime "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + lodash "^4.17.4" + +babel-traverse@^6.24.1, babel-traverse@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" + dependencies: + babel-code-frame "^6.26.0" + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" + +babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" + dependencies: + babel-runtime "^6.26.0" + esutils "^2.0.2" + lodash "^4.17.4" + to-fast-properties "^1.0.3" + babel@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel/-/babel-6.23.0.tgz#d0d1e7d803e974765beea3232d4e153c0efb90f4" +babylon@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" + balanced-match@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -182,6 +678,14 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +braces@^1.8.2: + version "1.8.5" + resolved "https://registry.yarnpkg.com/braces/-/braces-1.8.5.tgz#ba77962e12dff969d6b76711e914b737857bf6a7" + dependencies: + expand-range "^1.8.1" + preserve "^0.2.0" + repeat-element "^1.1.2" + braces@^2.3.0, braces@^2.3.1: version "2.3.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" @@ -201,6 +705,13 @@ browser-stdout@1.3.1: version "1.3.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60" +browserslist@^3.2.6: + version "3.2.8" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-3.2.8.tgz#b0005361d6471f0f5952797a76fc985f1f978fc6" + dependencies: + caniuse-lite "^1.0.30000844" + electron-to-chromium "^1.3.47" + buffer-from@^1.0.0: version "1.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -237,6 +748,10 @@ camelcase@^4.0.0: version "4.1.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" +caniuse-lite@^1.0.30000844: + version "1.0.30000874" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000874.tgz#a641b1f1c420d58d9b132920ef6ba87bbdcd2223" + capture-stack-trace@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d" @@ -278,6 +793,21 @@ check-error@^1.0.1: version "1.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" +chokidar@^1.6.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + chokidar@^2.0.2: version "2.0.4" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/chokidar/-/chokidar-2.0.4.tgz#356ff4e2b0e8e43e322d18a372460bbcf3accd26" @@ -361,6 +891,10 @@ commander@2.15.1: version "2.15.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" +commander@^2.11.0: + version "2.17.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" + component-emitter@^1.2.1: version "1.2.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" @@ -397,10 +931,18 @@ contains-path@^0.1.0: version "0.1.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" +convert-source-map@^1.5.0, convert-source-map@^1.5.1: + version "1.5.1" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" + copy-descriptor@^0.1.0: version "0.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" +core-js@^2.4.0, core-js@^2.5.0: + version "2.5.7" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e" + core-util-is@~1.0.0: version "1.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -495,6 +1037,12 @@ delegates@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a" +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + dependencies: + repeating "^2.0.0" + detect-libc@^1.0.2: version "1.0.3" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" @@ -530,6 +1078,10 @@ duplexer@~0.1.1: version "0.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" +electron-to-chromium@^1.3.47: + version "1.3.56" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.56.tgz#aad1420d23e9dd8cd2fc2bc53f4928adcf85f02f" + error-ex@^1.2.0: version "1.3.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/error-ex/-/error-ex-1.3.2.tgz#b4ac40648107fdcdcfae242f428bea8a14d4f1bf" @@ -721,6 +1273,12 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +expand-brackets@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-0.1.5.tgz#df07284e342a807cd733ac5af72411e581d1177b" + dependencies: + is-posix-bracket "^0.1.0" + expand-brackets@^2.1.4: version "2.1.4" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" @@ -733,6 +1291,12 @@ expand-brackets@^2.1.4: snapdragon "^0.8.1" to-regex "^3.0.1" +expand-range@^1.8.1: + version "1.8.2" + resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" + dependencies: + fill-range "^2.1.0" + extend-shallow@^2.0.1: version "2.0.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" @@ -754,6 +1318,12 @@ external-editor@^2.0.4: iconv-lite "^0.4.17" tmp "^0.0.33" +extglob@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" + dependencies: + is-extglob "^1.0.0" + extglob@^2.0.4: version "2.0.4" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" @@ -796,6 +1366,20 @@ file-entry-cache@^2.0.0: flat-cache "^1.2.1" object-assign "^4.0.1" +filename-regex@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" + +fill-range@^2.1.0: + version "2.2.4" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-2.2.4.tgz#eb1e773abb056dcd8df2bfdf6af59b8b3a936565" + dependencies: + is-number "^2.1.0" + isobject "^2.0.0" + randomatic "^3.0.0" + repeat-element "^1.1.2" + repeat-string "^1.5.2" + fill-range@^4.0.0: version "4.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" @@ -827,10 +1411,16 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" -for-in@^1.0.2: +for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" +for-own@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/for-own/-/for-own-0.1.5.tgz#5265c681a4f294dabbf17c9509b6763aa84510ce" + dependencies: + for-in "^1.0.1" + foreach@^2.0.5: version "2.0.5" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" @@ -851,11 +1441,15 @@ fs-minipass@^1.2.5: dependencies: minipass "^2.2.1" +fs-readdir-recursive@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" + fs.realpath@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" -fsevents@^1.2.2: +fsevents@^1.0.0, fsevents@^1.2.2: version "1.2.4" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/fsevents/-/fsevents-1.2.4.tgz#f41dcb1af2582af3692da36fc55cbd8e1041c426" dependencies: @@ -899,6 +1493,19 @@ get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" +glob-base@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" + dependencies: + glob-parent "^2.0.0" + is-glob "^2.0.0" + +glob-parent@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28" + dependencies: + is-glob "^2.0.0" + glob-parent@^3.1.0: version "3.1.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" @@ -927,6 +1534,10 @@ globals@^11.0.1: version "11.7.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673" +globals@^9.18.0: + version "9.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" + globby@^5.0.0: version "5.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d" @@ -954,7 +1565,7 @@ got@^6.7.1: unzip-response "^2.0.1" url-parse-lax "^1.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.2: +graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4: version "4.1.11" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" @@ -1017,6 +1628,13 @@ he@1.1.1: version "1.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd" +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + hosted-git-info@^2.1.4: version "2.7.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/hosted-git-info/-/hosted-git-info-2.7.1.tgz#97f236977bd6e125408930ff6de3eec6281ec047" @@ -1091,6 +1709,12 @@ inquirer@^3.0.6: strip-ansi "^4.0.0" through "^2.3.6" +invariant@^2.2.2: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + dependencies: + loose-envify "^1.0.0" + is-accessor-descriptor@^0.1.6: version "0.1.6" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" @@ -1165,6 +1789,16 @@ is-descriptor@^1.0.0, is-descriptor@^1.0.2: is-data-descriptor "^1.0.0" kind-of "^6.0.2" +is-dotfile@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" + +is-equal-shallow@^0.1.3: + version "0.1.3" + resolved "https://registry.yarnpkg.com/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz#2238098fc221de0bcfa5d9eac4c45d638aa1c534" + dependencies: + is-primitive "^2.0.0" + is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" @@ -1175,10 +1809,20 @@ is-extendable@^1.0.1: dependencies: is-plain-object "^2.0.4" +is-extglob@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" + is-extglob@^2.1.0, is-extglob@^2.1.1: version "2.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" +is-finite@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.0.2.tgz#cc6677695602be550ef11e8b4aa6305342b6d0aa" + dependencies: + number-is-nan "^1.0.0" + is-fullwidth-code-point@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz#ef9e31386f031a7f0d643af82fde50c457ef00cb" @@ -1189,6 +1833,12 @@ is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" +is-glob@^2.0.0, is-glob@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" + dependencies: + is-extglob "^1.0.0" + is-glob@^3.1.0: version "3.1.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" @@ -1212,12 +1862,22 @@ is-npm@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-npm/-/is-npm-1.0.0.tgz#f2fb63a65e4905b406c86072765a1a4dc793b9f4" +is-number@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" + dependencies: + kind-of "^3.0.2" + is-number@^3.0.0: version "3.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" dependencies: kind-of "^3.0.2" +is-number@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff" + is-obj@^1.0.0: version "1.0.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" @@ -1244,6 +1904,14 @@ is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: dependencies: isobject "^3.0.1" +is-posix-bracket@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" + +is-primitive@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" + is-promise@^2.1.0: version "2.1.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" @@ -1300,6 +1968,10 @@ jest-docblock@^21.0.0: version "21.2.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" +"js-tokens@^3.0.0 || ^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + js-tokens@^3.0.2: version "3.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" @@ -1311,6 +1983,14 @@ js-yaml@^3.9.1: argparse "^1.0.7" esprima "^4.0.0" +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + +jsesc@~0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" + json-schema-traverse@^0.3.0: version "0.3.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" @@ -1319,6 +1999,10 @@ json-stable-stringify-without-jsonify@^1.0.1: version "1.0.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" +json5@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -1376,6 +2060,12 @@ lodash@^4.17.10, lodash@^4.17.4, lodash@^4.3.0: version "4.17.10" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" +loose-envify@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + lowercase-keys@^1.0.0: version "1.0.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" @@ -1407,6 +2097,28 @@ map-visit@^1.0.0: dependencies: object-visit "^1.0.0" +math-random@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.1.tgz#8b3aac588b8a66e4975e3cdea67f7bb329601fac" + +micromatch@^2.1.5: + version "2.3.11" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-2.3.11.tgz#86677c97d1720b363431d04d0d15293bd38c1565" + dependencies: + arr-diff "^2.0.0" + array-unique "^0.2.1" + braces "^1.8.2" + expand-brackets "^0.1.4" + extglob "^0.3.1" + filename-regex "^2.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.1" + kind-of "^3.0.2" + normalize-path "^2.0.1" + object.omit "^2.0.0" + parse-glob "^3.0.4" + regex-cache "^0.4.2" + micromatch@^3.1.4: version "3.1.10" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" @@ -1581,7 +2293,7 @@ normalize-path@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/normalize-path/-/normalize-path-1.0.0.tgz#32d0e472f91ff345701c15a8311018d3b0a90379" -normalize-path@^2.1.1: +normalize-path@^2.0.0, normalize-path@^2.0.1, normalize-path@^2.1.1: version "2.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" dependencies: @@ -1657,6 +2369,13 @@ object.entries@^1.0.4: function-bind "^1.1.0" has "^1.0.1" +object.omit@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/object.omit/-/object.omit-2.0.1.tgz#1a9c744829f39dbb858c76ca3579ae2a54ebd1fa" + dependencies: + for-own "^0.1.4" + is-extendable "^0.1.1" + object.pick@^1.3.0: version "1.3.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" @@ -1690,7 +2409,7 @@ os-homedir@^1.0.0: version "1.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" -os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -1701,6 +2420,14 @@ osenv@^0.1.4: os-homedir "^1.0.0" os-tmpdir "^1.0.0" +output-file-sync@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" + dependencies: + graceful-fs "^4.1.4" + mkdirp "^0.5.1" + object-assign "^4.1.0" + p-finally@^1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -1730,6 +2457,15 @@ package-json@^4.0.0: registry-url "^3.0.3" semver "^5.1.0" +parse-glob@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/parse-glob/-/parse-glob-3.0.4.tgz#b2c376cfb11f35513badd173ef0bb6e3a388391c" + dependencies: + glob-base "^0.3.0" + is-dotfile "^1.0.0" + is-extglob "^1.0.0" + is-glob "^2.0.0" + parse-json@^2.2.0: version "2.2.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9" @@ -1754,7 +2490,7 @@ path-exists@^3.0.0: version "3.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" -path-is-absolute@^1.0.0: +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -1826,10 +2562,18 @@ prepend-http@^1.0.1: version "1.0.4" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" +preserve@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" + prettier@^1.14.0: version "1.14.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/prettier/-/prettier-1.14.0.tgz#847c235522035fd988100f1f43cf20a7d24f9372" +private@^0.1.6, private@^0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" + process-nextick-args@~2.0.0: version "2.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" @@ -1854,6 +2598,14 @@ pstree.remy@^1.1.0: dependencies: ps-tree "^1.1.0" +randomatic@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-3.1.0.tgz#36f2ca708e9e567f5ed2ec01949026d50aa10116" + dependencies: + is-number "^4.0.0" + kind-of "^6.0.0" + math-random "^1.0.1" + rc@^1.0.1, rc@^1.1.6, rc@^1.2.7: version "1.2.8" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" @@ -1899,6 +2651,32 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" +regenerate@^1.2.1: + version "1.4.0" + resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11" + +regenerator-runtime@^0.10.5: + version "0.10.5" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" + +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + +regenerator-transform@^0.10.0: + version "0.10.1" + resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.10.1.tgz#1e4996837231da8b7f3cf4114d71b5691a0680dd" + dependencies: + babel-runtime "^6.18.0" + babel-types "^6.19.0" + private "^0.1.6" + +regex-cache@^0.4.2: + version "0.4.4" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" + dependencies: + is-equal-shallow "^0.1.3" + regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" @@ -1910,6 +2688,14 @@ regexpp@^1.0.1: version "1.1.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/regexpp/-/regexpp-1.1.0.tgz#0e3516dd0b7904f413d2d4193dce4618c3a689ab" +regexpu-core@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-2.0.0.tgz#49d038837b8dcf8bfa5b9a42139938e6ea2ae240" + dependencies: + regenerate "^1.2.1" + regjsgen "^0.2.0" + regjsparser "^0.1.4" + registry-auth-token@^3.0.1: version "3.3.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/registry-auth-token/-/registry-auth-token-3.3.2.tgz#851fd49038eecb586911115af845260eec983f20" @@ -1923,6 +2709,16 @@ registry-url@^3.0.3: dependencies: rc "^1.0.1" +regjsgen@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/regjsgen/-/regjsgen-0.2.0.tgz#6c016adeac554f75823fe37ac05b92d5a4edb1f7" + +regjsparser@^0.1.4: + version "0.1.5" + resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.1.5.tgz#7ee8f84dc6fa792d3fd0ae228d24bd949ead205c" + dependencies: + jsesc "~0.5.0" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -1931,10 +2727,16 @@ repeat-element@^1.1.2: version "1.1.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" -repeat-string@^1.6.1: +repeat-string@^1.5.2, repeat-string@^1.6.1: version "1.6.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + dependencies: + is-finite "^1.0.0" + require-uncached@^1.0.3: version "1.0.3" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" @@ -2057,6 +2859,10 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + slice-ansi@1.0.0: version "1.0.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" @@ -2100,11 +2906,17 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" +source-map-support@^0.4.15: + version "0.4.18" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" + dependencies: + source-map "^0.5.6" + source-map-url@^0.4.0: version "0.4.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" -source-map@^0.5.6: +source-map@^0.5.6, source-map@^0.5.7: version "0.5.7" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -2265,6 +3077,10 @@ tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" +to-fast-properties@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" + to-object-path@^0.3.0: version "0.3.0" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" @@ -2293,6 +3109,10 @@ touch@^3.1.0: dependencies: nopt "~1.0.10" +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + type-check@~0.3.2: version "0.3.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/type-check/-/type-check-0.3.2.tgz#5884cab512cf1d355e3fb784f30804b2b520db72" @@ -2372,10 +3192,20 @@ use@^3.1.0: version "3.1.1" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" +user-home@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" + util-deprecate@~1.0.1: version "1.0.2" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" +v8flags@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" + dependencies: + user-home "^1.1.1" + validate-npm-package-license@^3.0.1: version "3.0.4" resolved "http://artifactory.cdk.com/artifactory/api/npm/npm-repo/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" From 82f61817bb29d56043677f216dd16f72df1e84d6 Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Fri, 10 Aug 2018 07:33:36 -0700 Subject: [PATCH 04/17] Updated tests, added typechecking --- README.md | 50 +++++++++++++++++++++++++++++++++++++-------- package.json | 2 +- src/Number/index.js | 9 ++++++++ src/Object/index.js | 12 +++++++++++ src/String/index.js | 11 ++++++++++ test/Array.test.js | 13 +++++++++++- test/Number.test.js | 14 +++++++++++++ test/Object.test.js | 26 +++++++++++++++++++++++ test/String.test.js | 13 ++++++++---- 9 files changed, 136 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index d4b36c3..d5192c4 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ An extension to the Javascript Object, Array, and String prototype chain. Extend ### Features -- Small package size (29.1kB) +- Small package size (~29.1kB) - Well tested - Easy to install - JSdoc documentated @@ -174,13 +174,6 @@ console.log(foo.toArray()) // => [1,2,3] ``` -### *Object.forEach()* -Loop over the key value pair in the object - -```javascript - - -``` ### *Object.deepCopy()* Deep copy the object with `JSON.parse(JSON.stringify())`, erasing any object references @@ -209,6 +202,26 @@ console.log(obj1.deepEqual(obj2)) ``` +### *Object.isObject()* +Checks to see if the value passed in is an object (not arrays or functions) +**Also on the actual Object not on the prototype chain** +``` javascript +const foo = {} +const bar = [] +const baz = function() { return 2} + +console.log(Object.isObject(foo)) +// => true + +console.log(Object.isObject(bar)) +// => false + +console.log(Object.isObject(baz)) +// => false + +``` + + ## Array Methods: ### *Array.first* A getter to easily get the *first* element of an array @@ -422,6 +435,15 @@ console.log(str.contains('fox')) // => true ``` +### *String.isString()* +Check to see if the value is a string (On the actual `String` object) +``` javascript +const str = 'Hello world!' + +console.log(String.isString(str)) +// => true +``` + ## Number Methods @@ -448,6 +470,18 @@ console.log(Number.random(0,5)) ``` +### *Number.isNumber()* +Check to see if the value is a number or not (On the `Number` object not prototype chain) + +```javascript +const num = 12345 + + +console.log(Number.isNumber(num)) +// => true +``` + + ## Contributing Please feel free to add an issue, or create a pull request to add extra functionality to the prototype chain. However, I don't want to pollute the chain with the entire library of lodash persay, just the most useful functions. diff --git a/package.json b/package.json index 57fcb09..97e8c58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perfected-prototypes", - "version": "1.8.0", + "version": "1.9.0", "description": "An easy way to extend the built in Javascript prototype chains and make JS fun again", "main": "index.js", "scripts": { diff --git a/src/Number/index.js b/src/Number/index.js index ea1e52d..bf0e0cc 100644 --- a/src/Number/index.js +++ b/src/Number/index.js @@ -25,5 +25,14 @@ mainNum.random = function randomGen(start, stop) { return random(start, stop); }; +/** + * Check to see if the value is a number or not + * @param {number} num - The value to check + * @returns {boolean} + */ +mainNum.isNumber = function isNumber(num) { + return typeof num === 'number'; +}; + mergeExtension(Number, mainNum); mergeExtension(Number.prototype, newNum); diff --git a/src/Object/index.js b/src/Object/index.js index 450314e..0514705 100644 --- a/src/Object/index.js +++ b/src/Object/index.js @@ -1,9 +1,11 @@ const safeD = require('lodash/get'); +const lodashIsObject = require('lodash/isPlainObject'); const merger = require('lodash/merge'); const { mergeExtension } = require('./../merger'); const newObject = {}; +const mainObj = {}; /** * Safely access values within the object and return undefined if value not present @@ -14,6 +16,15 @@ newObject.try = function safe(dereference) { return safeD(this, dereference, undefined); }; +/** + * Checks to see if the obj is really an object (not array or function) + * @param {[*]} potentialObj - The value to determine if an object or not + * @returns {boolean} + */ +mainObj.isObject = function isObj(potentialObj) { + return lodashIsObject(potentialObj); +}; + /** * Check to see if the object is empty and has no values * @returns {boolean} @@ -103,3 +114,4 @@ newObject.reduce = function reduce(func, accumulator) { }; mergeExtension(Object.prototype, newObject); +mergeExtension(Object, mainObj); diff --git a/src/String/index.js b/src/String/index.js index 3a22698..8a30448 100644 --- a/src/String/index.js +++ b/src/String/index.js @@ -5,6 +5,7 @@ const escape = require('lodash/escape'); const { assignExtensions } = require('./../merger'); const newString = {}; +const mainString = {}; /** * Insert appropriate commas into a string of numbers @@ -47,4 +48,14 @@ newString.contains = function contains(str) { return this.indexOf(str) !== -1; }; +/** + * Checks to see if the value is a string or not + * @param {string} str - the string to check + * @returns {boolean} + */ +mainString.isString = function isString(str) { + return typeof str === 'string'; +}; + assignExtensions(String.prototype, newString); +assignExtensions(String, mainString); diff --git a/test/Array.test.js b/test/Array.test.js index 1b084f5..937d4d2 100644 --- a/test/Array.test.js +++ b/test/Array.test.js @@ -10,21 +10,32 @@ describe('array prototype', () => { ]; describe('Array first getter', () => { + const array = [] + it('should return 1', () => { assert.equal(arr.first, 1) }) + + it('should return undefined', () => { + assert.equal(array.first, undefined) + }) }) describe('Array last getter', () => { + const array = [] it('should return 3', () => { assert.equal(arr.last, 9) }) + + it('should return undefined', () => { + assert.equal(array.last, undefined) + }) }) describe('Array shuffle prototype', () => { - it('should return 3', () => { + it('should not equal the array from it was called on.', () => { assert.notDeepEqual(arr.shuffle(), arr) }) }) diff --git a/test/Number.test.js b/test/Number.test.js index 447a03b..fabc7db 100644 --- a/test/Number.test.js +++ b/test/Number.test.js @@ -26,4 +26,18 @@ describe('Number prototype chain', () => { expect(Number.random(0, 5)).to.be.lte(5) }) }) + + describe('Number isNumber prototype', () => { + it('should return true for an actual number', () => { + const num = 12355 + + assert.equal(Number.isNumber(num), true) + }) + + it('should return false for a string of numbers', () => { + const notNum = '12345' + + assert.equal(Number.isNumber(notNum), false) + }) + }) }) \ No newline at end of file diff --git a/test/Object.test.js b/test/Object.test.js index 70994c4..066cf1c 100644 --- a/test/Object.test.js +++ b/test/Object.test.js @@ -42,6 +42,23 @@ describe('Object prototypes', () => { }) }) + describe('isObject object method', () => { + it('should return true for an actual object', () => { + const obj = {} + assert.equal(Object.isObject(obj), true) + }) + + it('should return FALSE for an array', () => { + const notObj = [] + assert.equal(Object.isObject(notObj), false) + }) + + it('should return FALSE for a function', () => { + const notObj = function() { return 1 } + assert.equal(Object.isObject(notObj), false) + }) + }) + describe('merge object method', () => { it('should merge two object together', () => { let obj1 = { a: 1 } @@ -68,6 +85,15 @@ describe('Object prototypes', () => { }) assert.deepEqual(res, { a1: 2, b1: 4 }) }) + + it('should return an empty object', () => { + const foo = { a: 1, b: 2 } + let res = foo.mapOver((key, val) => { + key = key + '1' + val = val * 2 + }) + assert.deepEqual(res, {}) + }) }) describe('Object forEach prototype', () => { diff --git a/test/String.test.js b/test/String.test.js index 650e999..36a2216 100644 --- a/test/String.test.js +++ b/test/String.test.js @@ -50,10 +50,15 @@ describe('String prototype', () => { }) }) - describe('String unique prototype', () => { - it('should give back a unique set of elements from the list', () => { - const arr = [1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 5, 6] - assert.deepEqual(arr.unique(), [1, 2, 3, 4, 5, 6]) + describe('String isString method', () => { + it('should return true for an actual string', () => { + const str = 'Im very sleepy' + assert.equal(String.isString(str), true) + }) + + it('should return false for a number', () => { + const notStr = 13245 + assert.equal(String.isString(notStr), false) }) }) }) \ No newline at end of file From 9c26fd495f2939fa55cacac2120d5a6da33b6647 Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Sun, 12 Aug 2018 18:20:49 -0700 Subject: [PATCH 05/17] Changed names of object methods that were conflicting with other packages --- README.md | 25 +++++++-------------- src/Object/index.js | 54 +++++++++++++++++++-------------------------- test/Object.test.js | 33 ++++++++------------------- 3 files changed, 40 insertions(+), 72 deletions(-) diff --git a/README.md b/README.md index d5192c4..df7f5b2 100644 --- a/README.md +++ b/README.md @@ -81,12 +81,12 @@ console.log(foo.try('a.b.c.d.e.f')) ``` -### *Object.forEach()* +### *Object.eachKeyValue()* Loop over each key and value returning undefined ``` javascript const foo = { a: 1, b: 2 } -foo.forEach((key, val) => { +foo.eachKeyValue((key, val) => { console.log(key, val) }) @@ -125,12 +125,12 @@ console.log(foo.reduce((prev, [key, val]) => {prev.push(val); return prev}, [])) -### *Object.isEmpty()* +### *Object.hasData()* Test to see if there is any values within your object ```javascript const foo = {} - console.log(foo.isEmpty()) + console.log(foo.hasData()) // => true ``` @@ -139,18 +139,18 @@ Test to see if there is any values within your object ```javascript const foo = {a:1} -console.log(foo.isEmpty()) +console.log(foo.hasData()) // => false ``` -### *Object.merge()* +### *Object.mergeObjects()* Merge one or any amount of objects together, with key/value presedence dependent on order of objects passed in ``` javascript const foo = {a:1} const bar = {b:2} -console.log(foo.merge(bar)) +console.log(foo.mergeObjects(bar)) // => {a:1, b:2} ``` @@ -161,19 +161,10 @@ const foo = {a:1} const bar = {b:2} const baz = {c:3} -console.log(foo.merge(bar,baz)) +console.log(foo.mergeObjects(bar,baz)) // => {a:1, b:2, c:3} ``` -### *Object.toArray()* -Really just `Object.values()`, but extracts all the values into an array -``` javascript -const foo = {a:1,b:2,c:3} - -console.log(foo.toArray()) -// => [1,2,3] -``` - ### *Object.deepCopy()* Deep copy the object with `JSON.parse(JSON.stringify())`, erasing any object references diff --git a/src/Object/index.js b/src/Object/index.js index 0514705..29c9470 100644 --- a/src/Object/index.js +++ b/src/Object/index.js @@ -13,7 +13,7 @@ const mainObj = {}; * @returns {*|undefined} The value being referenced OR undefined */ newObject.try = function safe(dereference) { - return safeD(this, dereference, undefined); + return safeD(this, dereference, undefined); }; /** @@ -22,15 +22,15 @@ newObject.try = function safe(dereference) { * @returns {boolean} */ mainObj.isObject = function isObj(potentialObj) { - return lodashIsObject(potentialObj); + return lodashIsObject(potentialObj); }; /** * Check to see if the object is empty and has no values * @returns {boolean} */ -newObject.isEmpty = function isEmpty() { - return Object.keys(this).length === 0; +newObject.hasData = function isEmpty() { + return Object.keys(this).length === 0; }; /** @@ -38,20 +38,12 @@ newObject.isEmpty = function isEmpty() { * @param {...object} objs - The objects passed in to be merged into the first * @returns {object} The new object merged together from the list of sources */ -newObject.merge = function merge(...objs) { - let mergedObj = this; - objs.forEach(obj => { - mergedObj = merger(this, obj); - }); - return mergedObj; -}; - -/** - * Turn the values of the object into an array - * @returns {[*]} - The values of the existing object - */ -newObject.toArray = function toArray() { - return Object.values(this); +newObject.mergeObjects = function merge(...objs) { + let mergedObj = this; + objs.forEach(obj => { + mergedObj = merger(this, obj); + }); + return mergedObj; }; /** @@ -60,7 +52,7 @@ newObject.toArray = function toArray() { * @returns {Object} - The new object with no references to the original */ newObject.deepCopy = function deepCopy() { - return JSON.parse(JSON.stringify(this)); + return JSON.parse(JSON.stringify(this)); }; /** @@ -70,7 +62,7 @@ newObject.deepCopy = function deepCopy() { */ newObject.deepEqual = function deepEqual(obj) { - return JSON.stringify(this) === JSON.stringify(obj); + return JSON.stringify(this) === JSON.stringify(obj); }; /** @@ -81,10 +73,10 @@ newObject.deepEqual = function deepEqual(obj) { * @returns {*} obj - The object returned from modification */ newObject.mapOver = function map(func) { - return Object.entries(this).reduce( - (prev, [key, val]) => merger(prev, func(key, val)), - {} - ); + return Object.entries(this).reduce( + (prev, [key, val]) => merger(prev, func(key, val)), + {} + ); }; /** @@ -94,9 +86,9 @@ newObject.mapOver = function map(func) { * @param {*} val - the value associated with the key * @returns {undefined} */ -newObject.forEach = function forEach(func) { - Object.entries(this).map(([key, val]) => func(key, val)); - return undefined; +newObject.eachKeyValue = function forEach(func) { + Object.entries(this).map(([key, val]) => func(key, val)); + return undefined; }; /** @@ -107,10 +99,10 @@ newObject.forEach = function forEach(func) { * @returns {*} The value accumulated */ newObject.reduce = function reduce(func, accumulator) { - return Object.entries(this).reduce( - (prev, [key, val]) => func(prev, [key, val]), - accumulator - ); + return Object.entries(this).reduce( + (prev, [key, val]) => func(prev, [key, val]), + accumulator + ); }; mergeExtension(Object.prototype, newObject); diff --git a/test/Object.test.js b/test/Object.test.js index 066cf1c..ba9b94e 100644 --- a/test/Object.test.js +++ b/test/Object.test.js @@ -30,15 +30,15 @@ describe('Object prototypes', () => { }) }); - describe('isEmpty object method', () => { + describe('hasData object method', () => { it('should return true since the object is empty', () => { const obj = {} - assert.equal(true, obj.isEmpty()) + assert.equal(true, obj.hasData()) }) - it('should return false since the objist is NOT empty', () => { + it('should return false since the obj is NOT empty', () => { const obj = { a: 1 } - assert.equal(false, obj.isEmpty()) + assert.equal(false, obj.hasData()) }) }) @@ -59,11 +59,11 @@ describe('Object prototypes', () => { }) }) - describe('merge object method', () => { + describe('mergeObjects method', () => { it('should merge two object together', () => { let obj1 = { a: 1 } let obj2 = { b: 2 } - assert.deepEqual(obj1.merge(obj2), { a: 1, b: 2 }) + assert.deepEqual(obj1.mergeObjects(obj2), { a: 1, b: 2 }) }) it('should merge multiple objects together', () => { @@ -71,7 +71,7 @@ describe('Object prototypes', () => { let obj2 = { b: 2 } let obj3 = { c: 3 } let obj4 = { d: 4 } - assert.deepEqual(obj1.merge(obj2, obj3, obj4), { a: 1, b: 2, c: 3, d: 4 }) + assert.deepEqual(obj1.mergeObjects(obj2, obj3, obj4), { a: 1, b: 2, c: 3, d: 4 }) }) }) @@ -96,10 +96,10 @@ describe('Object prototypes', () => { }) }) - describe('Object forEach prototype', () => { + describe('Object eachKeyValue prototype', () => { it('should match the key value pairs appropriately', () => { const foo = { a: 1, b: 2 } - foo.forEach((key, val) => { + foo.eachKeyValue((key, val) => { assert.equal(foo[key], val) }) }) @@ -125,21 +125,6 @@ describe('Object prototypes', () => { }) }) - - describe('toArray object method', () => { - it('should extract all the values from an object and return it as an array ', () => { - const obj = { - a: 1, - b: 2 - } - assert.deepEqual([1, 2], obj.toArray()) - }) - it('should return an empty array with an empty object ', () => { - const obj = {} - assert.deepEqual([], obj.toArray()) - }) - }) - describe('deepCopy object method', () => { it('should copy the object', () => { const obj = { a: { b: 2 } } From fcc4f585cec86fe81fbdfb397bf55c4eef0b3645 Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Sun, 12 Aug 2018 18:22:56 -0700 Subject: [PATCH 06/17] Changed package version --- package.json | 2 +- src/Object/index.js | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index 97e8c58..6d4a3d1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perfected-prototypes", - "version": "1.9.0", + "version": "2.0.0", "description": "An easy way to extend the built in Javascript prototype chains and make JS fun again", "main": "index.js", "scripts": { diff --git a/src/Object/index.js b/src/Object/index.js index 29c9470..bf13bd2 100644 --- a/src/Object/index.js +++ b/src/Object/index.js @@ -13,7 +13,7 @@ const mainObj = {}; * @returns {*|undefined} The value being referenced OR undefined */ newObject.try = function safe(dereference) { - return safeD(this, dereference, undefined); + return safeD(this, dereference, undefined); }; /** @@ -22,7 +22,7 @@ newObject.try = function safe(dereference) { * @returns {boolean} */ mainObj.isObject = function isObj(potentialObj) { - return lodashIsObject(potentialObj); + return lodashIsObject(potentialObj); }; /** @@ -30,7 +30,7 @@ mainObj.isObject = function isObj(potentialObj) { * @returns {boolean} */ newObject.hasData = function isEmpty() { - return Object.keys(this).length === 0; + return Object.keys(this).length === 0; }; /** @@ -39,11 +39,11 @@ newObject.hasData = function isEmpty() { * @returns {object} The new object merged together from the list of sources */ newObject.mergeObjects = function merge(...objs) { - let mergedObj = this; - objs.forEach(obj => { - mergedObj = merger(this, obj); - }); - return mergedObj; + let mergedObj = this; + objs.forEach(obj => { + mergedObj = merger(this, obj); + }); + return mergedObj; }; /** @@ -52,7 +52,7 @@ newObject.mergeObjects = function merge(...objs) { * @returns {Object} - The new object with no references to the original */ newObject.deepCopy = function deepCopy() { - return JSON.parse(JSON.stringify(this)); + return JSON.parse(JSON.stringify(this)); }; /** @@ -62,7 +62,7 @@ newObject.deepCopy = function deepCopy() { */ newObject.deepEqual = function deepEqual(obj) { - return JSON.stringify(this) === JSON.stringify(obj); + return JSON.stringify(this) === JSON.stringify(obj); }; /** @@ -73,10 +73,10 @@ newObject.deepEqual = function deepEqual(obj) { * @returns {*} obj - The object returned from modification */ newObject.mapOver = function map(func) { - return Object.entries(this).reduce( - (prev, [key, val]) => merger(prev, func(key, val)), - {} - ); + return Object.entries(this).reduce( + (prev, [key, val]) => merger(prev, func(key, val)), + {} + ); }; /** @@ -87,8 +87,8 @@ newObject.mapOver = function map(func) { * @returns {undefined} */ newObject.eachKeyValue = function forEach(func) { - Object.entries(this).map(([key, val]) => func(key, val)); - return undefined; + Object.entries(this).map(([key, val]) => func(key, val)); + return undefined; }; /** @@ -99,10 +99,10 @@ newObject.eachKeyValue = function forEach(func) { * @returns {*} The value accumulated */ newObject.reduce = function reduce(func, accumulator) { - return Object.entries(this).reduce( - (prev, [key, val]) => func(prev, [key, val]), - accumulator - ); + return Object.entries(this).reduce( + (prev, [key, val]) => func(prev, [key, val]), + accumulator + ); }; mergeExtension(Object.prototype, newObject); From b22930bcf78b00d33b554b720b81e6876e02704b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 13 Aug 2018 21:40:19 -0400 Subject: [PATCH 07/17] Added try/catch blocks --- src/merger.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/merger.js b/src/merger.js index 1ddb88d..5aab66f 100644 --- a/src/merger.js +++ b/src/merger.js @@ -2,13 +2,13 @@ exports.mergeExtension = function(prototype, newExtension) { for (var key in newExtension) { - if (prototype.hasOwnProperty(key)) { - console.warn(`${key} already exists on ${prototype}`); - continue; + try { + Object.defineProperty(prototype, key, { + value: newExtension[key] + }); + } catch (error) { + console.log(`${key} already exists on ${prototype}`); } - Object.defineProperty(prototype, key, { - value: newExtension[key] - }); } }; @@ -27,10 +27,10 @@ exports.assignExtensions = function(originalProto, extension) { exports.mergeGetters = (prototype, getter) => { for (var key in getter) { - if (prototype.hasOwnProperty(key)) { - console.warn(`${key} already exists on ${prototype}`); - continue; - } - Object.defineProperty(prototype, key, getter[key]); + try { + Object.defineProperty(prototype, key, getter[key]); + } catch (error) { + console.log(`${key} already exists on ${prototype}`); + } } }; From f68f05cf2619ae7beb403234bfcb1f58ea5ed863 Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Tue, 14 Aug 2018 08:46:10 -0700 Subject: [PATCH 08/17] Update package.json version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6d4a3d1..4c0b41c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perfected-prototypes", - "version": "2.0.0", + "version": "2.0.1", "description": "An easy way to extend the built in Javascript prototype chains and make JS fun again", "main": "index.js", "scripts": { From 129979495887ed913053ffbd26ad4f164f107896 Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Thu, 16 Aug 2018 13:35:45 -0700 Subject: [PATCH 09/17] Added uniqueBy command to filter arrays of objects --- README.md | 11 +++++++++++ package.json | 2 +- src/Array/extensions.js | 10 ++++++++++ src/merger.js | 2 +- test/Array.test.js | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index df7f5b2..afdd9f3 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,17 @@ console.log(arr.unique()) // => [1,2,3,4,5,6] ``` +### *Array.uniqueBy()* +Filter an array of objects to unique set of objects by some selector + +``` javascript +const arr = [{ name: 'bob', job: 'wood' }, { name: 'bob', job: 'wood' }] + +console.log(arr.uniqueBy('name')) +// => [{ name: 'bob', job: 'wood' }] + +``` + ### *Array.isEmpty()* Checks to see if the array is empty diff --git a/package.json b/package.json index 4c0b41c..a9e8f57 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perfected-prototypes", - "version": "2.0.1", + "version": "2.1.0", "description": "An easy way to extend the built in Javascript prototype chains and make JS fun again", "main": "index.js", "scripts": { diff --git a/src/Array/extensions.js b/src/Array/extensions.js index 5d63fe0..95de49a 100644 --- a/src/Array/extensions.js +++ b/src/Array/extensions.js @@ -2,6 +2,7 @@ const find = require('lodash/find'); const filter = require('lodash/filter'); const nth = require('lodash/nth'); const difference = require('lodash/difference'); +const uniqBy = require('lodash/uniqBy'); const extensionArray = {}; @@ -102,4 +103,13 @@ extensionArray.unique = function unique() { return [...new Set(this)]; }; +/** + * Get a unique set of objects within an array. + * @param {string} selector - the key of the object to filter unique values by + * @returns {array} of the unique values + */ +extensionArray.uniqueBy = function unique(selector) { + return uniqBy(this, selector); +}; + module.exports = extensionArray; diff --git a/src/merger.js b/src/merger.js index 5aab66f..6ecc9f2 100644 --- a/src/merger.js +++ b/src/merger.js @@ -31,6 +31,6 @@ exports.mergeGetters = (prototype, getter) => { Object.defineProperty(prototype, key, getter[key]); } catch (error) { console.log(`${key} already exists on ${prototype}`); - } + } } }; diff --git a/test/Array.test.js b/test/Array.test.js index 937d4d2..a22d673 100644 --- a/test/Array.test.js +++ b/test/Array.test.js @@ -146,6 +146,30 @@ describe('array prototype', () => { }) }) + describe('Array unique prototype', () => { + it('should remove all instances of the duplicates from the array', () => { + const arr = [1, 2, 2, 2, 2, 3, 4, 5, 6, 7] + assert.deepEqual(arr.unique(), [1, 2, 3, 4, 5, 6, 7]) + }) + + it('should remove all instances of the string from the array', () => { + const arr = ['bob', 'tom', 'joe', 'joe', 'joe'] + assert.deepEqual(arr.unique(), ['bob', 'tom', 'joe',]) + }) + }) + + describe('Array uniqueBy prototype', () => { + it('should remove all instances of the duplicate objects from the array', () => { + const arr = [{ name: 'bob', job: 'wood' }, { name: 'bob', job: 'wood' }] + assert.deepEqual(arr.uniqueBy('name'), [{ name: 'bob', job: 'wood' }]) + }) + + it('should remove all instances of the duplicate objects from the array', () => { + const arr = [{ name: 'bob', job: 'wood' }, { name: 'bob', job: 'wood' }] + assert.deepEqual(arr.uniqueBy('job'), [{ name: 'bob', job: 'wood' }]) + }) + }) + describe('Array findObj all prototype', () => { it('should find all elements in the array matching the findObj function', () => { const res = users.findAllObj(o => { return o.age < 40 }) From 7880d2ef572b54f45d149ecf782d6abacd31eb44 Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Thu, 16 Aug 2018 14:43:30 -0700 Subject: [PATCH 10/17] Added support for all caps to camel and capital case --- package.json | 2 +- src/String/index.js | 4 ++-- test/String.test.js | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a9e8f57..50e0c53 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "perfected-prototypes", - "version": "2.1.0", + "version": "2.1.1", "description": "An easy way to extend the built in Javascript prototype chains and make JS fun again", "main": "index.js", "scripts": { diff --git a/src/String/index.js b/src/String/index.js index 8a30448..2c14b81 100644 --- a/src/String/index.js +++ b/src/String/index.js @@ -20,7 +20,7 @@ newString.numberize = function numberize() { * @returns {string} */ newString.startCase = function startcase() { - return startCase(this); + return startCase(this.toLowerCase()); }; /** @@ -28,7 +28,7 @@ newString.startCase = function startcase() { * @returns {string} */ newString.camelCase = function camelcase() { - return camelCase(this); + return camelCase(this.toLowerCase()); }; /** diff --git a/test/String.test.js b/test/String.test.js index 36a2216..1937ca4 100644 --- a/test/String.test.js +++ b/test/String.test.js @@ -22,6 +22,11 @@ describe('String prototype', () => { const str = 'brandon dring' assert.equal(str.startCase(), 'Brandon Dring') }) + + it('should turn BRANDON DRING to Brandon Dring', () => { + const str = 'BRANDON DRING' + assert.equal(str.startCase(), 'Brandon Dring') + }) }) describe('Camel Case', () => { @@ -29,6 +34,11 @@ describe('String prototype', () => { const str = 'Brandon Dring' assert.equal(str.camelCase(), 'brandonDring') }) + + it('should turn BRANDON DRING to brandonDring', () => { + const str = 'BRANDON DRING' + assert.equal(str.camelCase(), 'brandonDring') + }) }) describe('HTML escape Case', () => { From 78b21d45e76fd6dcaae7b975e0b211e3c64861aa Mon Sep 17 00:00:00 2001 From: Ahmed Romih Date: Wed, 22 Aug 2018 09:55:15 +0300 Subject: [PATCH 11/17] Array assignment fixed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df7f5b2..2e17d3f 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ console.log(arr.access(-1)) Remove all instances of a value within the array and return new array ```javascript -const arr[1,2,2,3,4,5] +const arr = [1,2,2,3,4,5] console.log(arr.remove(2)) // => [1,3,4,5] From 9a9979f2257fa1db525a53085c42de1cf711a56b Mon Sep 17 00:00:00 2001 From: Ahmed Romih Date: Thu, 23 Aug 2018 22:38:57 +0300 Subject: [PATCH 12/17] Mutating the array itself --- src/Array/extensions.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Array/extensions.js b/src/Array/extensions.js index 5d63fe0..6a6db52 100644 --- a/src/Array/extensions.js +++ b/src/Array/extensions.js @@ -1,3 +1,4 @@ +const findIndex = require('lodash/findindex'); const find = require('lodash/find'); const filter = require('lodash/filter'); const nth = require('lodash/nth'); @@ -32,7 +33,21 @@ extensionArray.clear = function clear() { * @param {*} selector - The value trying to match against */ extensionArray.remove = function remove(selector) { - return this.filter(val => JSON.stringify(val) !== JSON.stringify(selector)); + if(selector !== null && typeof selector === 'object'){ + var index = findIndex(this, selector); + while(index >= 0){ + this.splice(index, 1); + // To prevent starting from the beginning of the array + index = findIndex(this, selector, index); + } + } else{ + var index = this.indexOf(selector); + while(index >= 0){ + this.splice(index, 1); + index = this.indexOf(selector, index); + } + } + return this; }; /** From 4d0593d9cfec563015bd94e4b1997c8cbb82ad51 Mon Sep 17 00:00:00 2001 From: Ahmed Romih Date: Fri, 24 Aug 2018 00:29:03 +0300 Subject: [PATCH 13/17] Updated require for lodash to be case sensitive --- src/Array/extensions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Array/extensions.js b/src/Array/extensions.js index 6a6db52..06ebd5c 100644 --- a/src/Array/extensions.js +++ b/src/Array/extensions.js @@ -1,4 +1,4 @@ -const findIndex = require('lodash/findindex'); +const findIndex = require('lodash/findIndex'); const find = require('lodash/find'); const filter = require('lodash/filter'); const nth = require('lodash/nth'); @@ -38,7 +38,7 @@ extensionArray.remove = function remove(selector) { while(index >= 0){ this.splice(index, 1); // To prevent starting from the beginning of the array - index = findIndex(this, selector, index); + index = findIndex(this, selector, index); } } else{ var index = this.indexOf(selector); From 5b7a2ede4db9bff5a8eeca2162f5734cd29e832c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 4 Sep 2018 14:37:26 -0400 Subject: [PATCH 14/17] Added tests --- test/Array.test.js | 2 ++ test/ArrayModule.test.js | 1 + 2 files changed, 3 insertions(+) diff --git a/test/Array.test.js b/test/Array.test.js index 937d4d2..3653124 100644 --- a/test/Array.test.js +++ b/test/Array.test.js @@ -58,11 +58,13 @@ describe('array prototype', () => { it('should remove all elements of the array ', () => { const array = [1, 2, 2, 2, 2, 3, 4] assert.deepEqual(array.remove(2), [1, 3, 4]) + assert.deepEqual(array, [1, 3, 4]) }) it('should remove the object from the array ', () => { const array = [{ a: 1 }, { b: 2 }, { c: 3 }] assert.deepEqual(array.remove({ a: 1 }), [{ b: 2 }, { c: 3 }]) + assert.deepEqual(array, [{ b: 2 }, { c: 3 }]) }) }) diff --git a/test/ArrayModule.test.js b/test/ArrayModule.test.js index be528cb..a567ab7 100644 --- a/test/ArrayModule.test.js +++ b/test/ArrayModule.test.js @@ -35,6 +35,7 @@ describe('array prototype', () => { it('should remove all elements of the array ', () => { const array = [1, 2, 2, 2, 2, 3, 4] assert.deepEqual(array.remove(2), [1, 3, 4]) + assert.deepEqual(array, [1, 3, 4]) }) }) }) \ No newline at end of file From 1b1a11666d56382e8aefb774ab5355e5a2d95f3c Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 9 Sep 2018 19:26:36 -0400 Subject: [PATCH 15/17] Added yank function --- README.md | 16 ++++++++++++++++ src/Array/extensions.js | 24 ++++++++++++++++++++++++ test/Array.test.js | 16 ++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/README.md b/README.md index 2e17d3f..d511a51 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,22 @@ console.log(arr.remove(2)) // => [1,3,4,5] ``` +### *Array.yank()* +Returns and removes the specified values and mutates the actual array +``` javascript +const arr = [1,2,3,4,5] + +console.log(arr.yank(2)) +// => 2 +console.log(arr) +// => [1,3,4,5] + +console.log(arr.yank([3,4])) +// => [3,4] +console.log(arr) +// => [1,2,5] +``` + ### *Array.clear()* Clear the array being worked on, and return a new empty array ``` javascript diff --git a/src/Array/extensions.js b/src/Array/extensions.js index 06ebd5c..43649b0 100644 --- a/src/Array/extensions.js +++ b/src/Array/extensions.js @@ -50,6 +50,30 @@ extensionArray.remove = function remove(selector) { return this; }; +/** + * Remove all instances of a value within the array and return the removed value + * @param {*} value - The value trying to match against + */ +extensionArray.yank = function yank(value){ + if (value.constructor === Array) { + for (let i = 0; i < value.length; i++) { + if(this.includes(value[i])){ + this.remove(value[i]); + }else{ + // Remove it from the given array so when we return it, it doesnt + // return a number that was not removed + value.remove(value[i]); + } + } + return value; + } else if (this.includes(value)) { + this.remove(value); + return value; + } else{ + throw "Value not in the array"; + } +} + /** * Get the value of the array by the position of the index * @param {number} index - The value being accessed, supports negative indexing diff --git a/test/Array.test.js b/test/Array.test.js index 3653124..bf6de45 100644 --- a/test/Array.test.js +++ b/test/Array.test.js @@ -68,6 +68,22 @@ describe('array prototype', () => { }) }) + describe('Array yank prototype', () => { + it('should return removed values and mutate the array ', () => { + const array = [1, 2, 2, 2, 2, 3, 4] + assert.deepEqual(array.yank(2), 2) + assert.deepEqual(array, [1, 3, 4]) + + const array2 = [1, 2, 2, 2, 2, 3, 4] + assert.deepEqual(array2.yank([3,4]), [3,4]) + assert.deepEqual(array2, [1, 2, 2, 2, 2]) + + const array3 = [1, 2, 2, 2, 2, 3, 4] + assert.deepEqual(array3.yank([4,5]), [4]) + assert.deepEqual(array3, [1, 2, 2, 2, 2, 3]) + }) + }) + describe('Array findObj prototype', () => { it('should find the obj in the array with the findObj function', () => { const res = users.findObj(o => { return o.age < 40 }) From 6669f28ea8240dea82d2a4eaf6a218c1db07d107 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 16 Sep 2018 21:50:40 -0400 Subject: [PATCH 16/17] Added test cases and modifications to function --- src/Array/extensions.js | 5 ++++- test/Array.test.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Array/extensions.js b/src/Array/extensions.js index 43649b0..dfee3a6 100644 --- a/src/Array/extensions.js +++ b/src/Array/extensions.js @@ -53,6 +53,7 @@ extensionArray.remove = function remove(selector) { /** * Remove all instances of a value within the array and return the removed value * @param {*} value - The value trying to match against + * @returns {*} - Value removed from the array */ extensionArray.yank = function yank(value){ if (value.constructor === Array) { @@ -63,14 +64,16 @@ extensionArray.yank = function yank(value){ // Remove it from the given array so when we return it, it doesnt // return a number that was not removed value.remove(value[i]); + i -= 1; //array shrinks after removing so need to check previous element } } + if(value.isEmpty()) return null; return value; } else if (this.includes(value)) { this.remove(value); return value; } else{ - throw "Value not in the array"; + return null; } } diff --git a/test/Array.test.js b/test/Array.test.js index bf6de45..bff38cb 100644 --- a/test/Array.test.js +++ b/test/Array.test.js @@ -81,6 +81,16 @@ describe('array prototype', () => { const array3 = [1, 2, 2, 2, 2, 3, 4] assert.deepEqual(array3.yank([4,5]), [4]) assert.deepEqual(array3, [1, 2, 2, 2, 2, 3]) + + const array4 = [1, 2, 2, 2, 2, 3, 4] + assert.deepEqual(array4.yank(5), null) + assert.deepEqual(array4, [1, 2, 2, 2, 2, 3, 4]) + + assert.deepEqual(array4.yank([5,6,7]), null) + assert.deepEqual(array4, [1, 2, 2, 2, 2, 3, 4]) + + assert.deepEqual(array4.yank([5]), null) + assert.deepEqual(array4, [1, 2, 2, 2, 2, 3, 4]) }) }) From 2d680056929e099e8d679b1f2a265c6945e7265a Mon Sep 17 00:00:00 2001 From: Brandon Lee Dring Date: Wed, 12 Dec 2018 10:27:11 -0800 Subject: [PATCH 17/17] Added templates --- .github/CONTRIBUTING.md | 39 ++++++++++++++++++++++++++++++++ .github/ISSUE_TEMPLATE.md | 33 +++++++++++++++++++++++++++ .github/PULL_REQUEST_TEMPLATE.md | 36 +++++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 .github/CONTRIBUTING.md create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..35b603b --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# How to contribute + +There are a few guidelines that we need contributors to follow so that we are able to process requests as efficiently as possible. If you have any questions or concerns please feel free to contact us at [opensource@nike.com](mailto:opensource@nike.com). + +## Getting Started + +* Review our [Code of Conduct](https://github.com/Nike-Inc/nike-inc.github.io/blob/master/CONDUCT.md) +* Submit the [Individual Contributor License Agreement](https://www.clahub.com/agreements/Nike-Inc/fastbreak) +* Make sure you have a [GitHub account](https://github.com/signup/free) +* Submit a ticket for your issue, assuming one does not already exist. + * Clearly describe the issue including steps to reproduce when it is a bug. + * Make sure you fill in the earliest version that you know has the issue. +* Fork the repository on GitHub + +## Making Changes + +* Create a topic branch off of `master` before you start your work. + * Please avoid working directly on the `master` branch. +* Make commits of logical units. + * You may be asked to squash unnecessary commits down to logical units. +* Check for unnecessary whitespace with `git diff --check` before committing. +* Write meaningful, descriptive commit messages. +* Please follow existing code conventions when working on a file. + +## Submitting Changes + +* Push your changes to a topic branch in your fork of the repository. +* Submit a pull request to the repository in the Nike-Inc organization. +* After feedback has been given we expect responses within two weeks. After two weeks we may close the pull request if it isn't showing any activity. +* Bug fixes or features that lack appropriate tests may not be considered for merge. +* Changes that lower test coverage may not be considered for merge. + +# Additional Resources + +* [General GitHub documentation](https://help.github.com/) +* [GitHub pull request documentation](https://help.github.com/send-pull-requests/) +* [Nike's Code of Conduct](https://github.com/Nike-Inc/nike-inc.github.io/blob/master/CONDUCT.md) +* [Nike's Individual Contributor License Agreement](https://www.clahub.com/agreements/Nike-Inc/fastbreak) +* [Nike OSS](https://nike-inc.github.io/) \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..d7f0bbf --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,33 @@ + + +## Expected Behavior + + + +## Current Behavior + + + +## Possible Solution + + + +## Steps to Reproduce (for bugs) + + +1. +2. +3. +4. + + + +## Context + + + +## Your Environment + +* App Version used: +* Environment name and version: +* Operating System and version: diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..fab5004 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,36 @@ + + +## Description + + +## Related Issue + + + + + +## Motivation and Context + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Types of changes + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to change) + +## Checklist: + + +- [ ] My code follows the code style of this project. +- [ ] My change requires a change to the documentation. +- [ ] I have updated the documentation accordingly. +- [ ] I have read the **CONTRIBUTING** document. +- [ ] I have added tests to cover my changes. +- [ ] All new and existing tests passed.