From 5665d4792a3b6f2166239f3088a5cfb3f0c582bb Mon Sep 17 00:00:00 2001 From: King Date: Thu, 11 Jan 2018 05:24:06 -0500 Subject: [PATCH 1/7] added isObject snippet --- snippets/isObject.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 snippets/isObject.md diff --git a/snippets/isObject.md b/snippets/isObject.md new file mode 100644 index 000000000..bbad12a88 --- /dev/null +++ b/snippets/isObject.md @@ -0,0 +1,16 @@ +### isObject + +Returns a boolean determining if the passed value is an object or not. + +```js +const isObject = obj => obj === Object(obj); +``` + +```js +isObject([1, 2, 3, 4]); // true +isObject([]); // true +isObject(['Hello!']); // true +isObject({ a:1 }); // true +isObject({}); // true +isObject(true); // false +``` From 7ad435fcadf358b11e1ba159c83b051f52994f7f Mon Sep 17 00:00:00 2001 From: King Date: Thu, 11 Jan 2018 05:24:31 -0500 Subject: [PATCH 2/7] update decription --- snippets/isObject.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snippets/isObject.md b/snippets/isObject.md index bbad12a88..10008cccd 100644 --- a/snippets/isObject.md +++ b/snippets/isObject.md @@ -2,6 +2,10 @@ Returns a boolean determining if the passed value is an object or not. +Uses the `Object` constructor to create an object wrapper for the given value. +If the value is null or undefined, it will create and return an empty object +otherwise, it will return an object of a type that corresponds to the given value. + ```js const isObject = obj => obj === Object(obj); ``` From 3c2361e54bc72e84107fbd3b90f863b4e82e2bbc Mon Sep 17 00:00:00 2001 From: King Date: Thu, 11 Jan 2018 05:25:44 -0500 Subject: [PATCH 3/7] ran npm tagger & tagged type --- tag_database | 1 + 1 file changed, 1 insertion(+) diff --git a/tag_database b/tag_database index ee007d575..df3c266b9 100644 --- a/tag_database +++ b/tag_database @@ -84,6 +84,7 @@ isFunction:type,function isLowerCase:string,utility isNull:type isNumber:type,math +isObject:type isPrime:math isPrimitive:type,function,array,string isPromiseLike:type,function,promise From 086005917d967317dc2490d5834317e720c7ac18 Mon Sep 17 00:00:00 2001 From: King Date: Thu, 11 Jan 2018 05:27:49 -0500 Subject: [PATCH 4/7] ran npm tdd --- test/decapitalize/decapitalize.js | 2 ++ test/decapitalize/decapitalize.test.js | 13 +++++++++++++ test/flattenDepth/flattenDepth.js | 4 ++++ test/flattenDepth/flattenDepth.test.js | 13 +++++++++++++ test/isObject/isObject.js | 1 + test/isObject/isObject.test.js | 13 +++++++++++++ 6 files changed, 46 insertions(+) create mode 100644 test/decapitalize/decapitalize.js create mode 100644 test/decapitalize/decapitalize.test.js create mode 100644 test/flattenDepth/flattenDepth.js create mode 100644 test/flattenDepth/flattenDepth.test.js create mode 100644 test/isObject/isObject.js create mode 100644 test/isObject/isObject.test.js diff --git a/test/decapitalize/decapitalize.js b/test/decapitalize/decapitalize.js new file mode 100644 index 000000000..6e84e5d6e --- /dev/null +++ b/test/decapitalize/decapitalize.js @@ -0,0 +1,2 @@ +module.exports = decapitalize = ([first, ...rest], upperRest = false) => +first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); \ No newline at end of file diff --git a/test/decapitalize/decapitalize.test.js b/test/decapitalize/decapitalize.test.js new file mode 100644 index 000000000..5ce0e6f5c --- /dev/null +++ b/test/decapitalize/decapitalize.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const decapitalize = require('./decapitalize.js'); + +test('Testing decapitalize', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof decapitalize === 'function', 'decapitalize is a Function'); + //t.deepEqual(decapitalize(args..), 'Expected'); + //t.equal(decapitalize(args..), 'Expected'); + //t.false(decapitalize(args..), 'Expected'); + //t.throws(decapitalize(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/flattenDepth/flattenDepth.js b/test/flattenDepth/flattenDepth.js new file mode 100644 index 000000000..9e4606a75 --- /dev/null +++ b/test/flattenDepth/flattenDepth.js @@ -0,0 +1,4 @@ +module.exports = flattenDepth = (arr, depth = 1) => +depth != 1 +? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flattenDepth(v, depth - 1) : v), []) +: arr.reduce((a, v) => a.concat(v), []); \ No newline at end of file diff --git a/test/flattenDepth/flattenDepth.test.js b/test/flattenDepth/flattenDepth.test.js new file mode 100644 index 000000000..113fbce1e --- /dev/null +++ b/test/flattenDepth/flattenDepth.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const flattenDepth = require('./flattenDepth.js'); + +test('Testing flattenDepth', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof flattenDepth === 'function', 'flattenDepth is a Function'); + //t.deepEqual(flattenDepth(args..), 'Expected'); + //t.equal(flattenDepth(args..), 'Expected'); + //t.false(flattenDepth(args..), 'Expected'); + //t.throws(flattenDepth(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isObject/isObject.js b/test/isObject/isObject.js new file mode 100644 index 000000000..98dbe499e --- /dev/null +++ b/test/isObject/isObject.js @@ -0,0 +1 @@ +module.exports = isObject = obj => obj === Object(obj); \ No newline at end of file diff --git a/test/isObject/isObject.test.js b/test/isObject/isObject.test.js new file mode 100644 index 000000000..9688b131a --- /dev/null +++ b/test/isObject/isObject.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isObject = require('./isObject.js'); + +test('Testing isObject', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isObject === 'function', 'isObject is a Function'); + //t.deepEqual(isObject(args..), 'Expected'); + //t.equal(isObject(args..), 'Expected'); + //t.false(isObject(args..), 'Expected'); + //t.throws(isObject(args..), 'Expected'); + t.end(); +}); \ No newline at end of file From 4bf3aa304d55da79c1ef0dc6b4d3a341f81849a6 Mon Sep 17 00:00:00 2001 From: King Date: Thu, 11 Jan 2018 05:31:49 -0500 Subject: [PATCH 5/7] add basic examples test to isObject --- test/isObject/isObject.test.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/isObject/isObject.test.js b/test/isObject/isObject.test.js index 9688b131a..b9a2e77b1 100644 --- a/test/isObject/isObject.test.js +++ b/test/isObject/isObject.test.js @@ -5,9 +5,15 @@ test('Testing isObject', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof isObject === 'function', 'isObject is a Function'); + + t.true(isObject([1, 2, 3, 4]), 'isObject([1, 2, 3, 4]) is a object'); + t.true(isObject([]), 'isObject([]) is a object'); + t.true(isObject({ a:1 }), 'isObject({ a:1 }) is a object'); + t.false(isObject(true), 'isObject(true) is not a object'); + //t.deepEqual(isObject(args..), 'Expected'); //t.equal(isObject(args..), 'Expected'); //t.false(isObject(args..), 'Expected'); //t.throws(isObject(args..), 'Expected'); t.end(); -}); \ No newline at end of file +}); From 2f2701d4c1473832adf317b89ec83813cb9ad394 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 11 Jan 2018 12:37:26 +0200 Subject: [PATCH 6/7] Update isObject.md --- snippets/isObject.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/snippets/isObject.md b/snippets/isObject.md index 10008cccd..c4cc5ffa8 100644 --- a/snippets/isObject.md +++ b/snippets/isObject.md @@ -3,8 +3,7 @@ Returns a boolean determining if the passed value is an object or not. Uses the `Object` constructor to create an object wrapper for the given value. -If the value is null or undefined, it will create and return an empty object -otherwise, it will return an object of a type that corresponds to the given value. +If the value is `null` or `undefined`, create and return an empty object. Οtherwise, return an object of a type that corresponds to the given value. ```js const isObject = obj => obj === Object(obj); From 0e6bf120c9ea44254085013c8329367c650f619a Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 11 Jan 2018 12:37:53 +0200 Subject: [PATCH 7/7] Update tag_database --- tag_database | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tag_database b/tag_database index df3c266b9..9752b3371 100644 --- a/tag_database +++ b/tag_database @@ -84,7 +84,7 @@ isFunction:type,function isLowerCase:string,utility isNull:type isNumber:type,math -isObject:type +isObject:type,object isPrime:math isPrimitive:type,function,array,string isPromiseLike:type,function,promise