Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "mitsuketa", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A Javascript library that enables you to handle deeply nested objects easily.", | ||
@@ -5,0 +5,0 @@ "main": "mitsuketa.js", |
246
readme.md
@@ -22,54 +22,264 @@ # Mitsuketa | ||
Mitsuketa makes JavaScript easier by taking the hassle out of working with deeply nested data structures. | ||
Mitsuketa makes JavaScript easier by taking the hassle out of working with deeply nested data structures. Allows you to strict compare object, locate deeply nested entities, etc. | ||
## Examples | ||
deepGet(*collection*, *identity*) | ||
Dummy object used in examples: | ||
``` | ||
Give an example | ||
const complexObject = { | ||
A : { | ||
Example : { | ||
DeeplyNested : { | ||
SamePropName : 'SamePropName1', | ||
OtherProperty : ['One','Two','Three'], | ||
AnotherProperty : { type: 'test' } | ||
} | ||
} | ||
}, | ||
B : '100', | ||
C : { | ||
SamePropName : 'SamePropName2', | ||
OtherProperty : ['x','y','z'] | ||
}, | ||
D : { | ||
A : 100, | ||
B : 'a string', | ||
C : [ | ||
{ | ||
name : 'Andrew Redican', | ||
id : 1, | ||
description: 'this is a description HELLO' | ||
}, | ||
{ | ||
name : 'John Teage', | ||
id : 2, | ||
description: 'this is a description WORLD' | ||
} | ||
] | ||
}, | ||
E : { | ||
ANumber : 7, | ||
OtherProperty : 'check this out' | ||
} | ||
} | ||
``` | ||
locate(*collection*, *identity*) | ||
deepGet( *collection*, *identity* ) | ||
``` | ||
Give an example | ||
deepGet(complexObject, 2) | ||
// returns: {name: "John Teage", id: 2, description: "this is a description WORLD"} | ||
deepGet(complexObject, { id : 1 }) | ||
// returns: {name: "Andrew Redican", id: 1, description: "this is a description HELLO"} | ||
deepGet(complexObject, '7') | ||
// returns: undefined | ||
deepGet(complexObject, 'this is a description WORLD') | ||
// returns: {name: "John Teage", id: 2, description: "this is a description WORLD"} | ||
deepGet(complexObject, 'x') | ||
// returns: ["x", "y", "z"] | ||
deepGet(complexObject, { type: 'test' }) | ||
// returns: {type: "test"} | ||
``` | ||
identical(*identityA*,*identityB*) | ||
locate( *collection*, *identity* ) | ||
``` | ||
Give an example | ||
locate(complexObject, 2) | ||
// returns: D.C.1.id | ||
locate(complexObject, { id : 1 }) | ||
// returns: D.C.0 | ||
locate(complexObject, '7') | ||
// returns: false | ||
locate(complexObject, 'this is a description WORLD') | ||
// returns: D.C.1.description | ||
locate(complexObject, 'x') | ||
// returns: C.OtherProperty.0 | ||
locate(complexObject, { type: 'test' }) | ||
// returns: A.Example.DeeplyNested.AnotherProperty | ||
``` | ||
trim(*identity*,*keyList*) | ||
identical( *identityA*, *identityB* ) | ||
``` | ||
Give an example | ||
const test = '5'; | ||
identical(test,'5') // returns: true | ||
identical(test, 5 ) // returns: false | ||
identical(test,[5]) // returns: false | ||
/** | ||
/* identical makes deep comparision between entities. | ||
/* Makes distintiction between datatypes, values, properties, | ||
/* iterables ( Object !== Array), and child/nested entities. | ||
**/ | ||
``` | ||
containsKeys(*identity*,*keyList*) | ||
trim( *identity*, *keyList* ) | ||
``` | ||
Give an example | ||
const O = { | ||
propA : 'Test', | ||
propB: [1,2,3], | ||
propC: { | ||
name: 'mitsuketa', | ||
type : 'javascript' | ||
}, | ||
propD: 37 | ||
}; | ||
trim(O,['propA','propB']) | ||
returns { propA : 'Test', propB: [1,2,3] } | ||
trim(O,[]) | ||
trim({},['propA','propB']) | ||
trim([],['propA','propB']) | ||
// returns undefined | ||
``` | ||
sameStructure(*identityA*,*identityB*) | ||
isIterable( *identity* ) | ||
``` | ||
Give an example | ||
isIterable(5) | ||
// returns false | ||
isIterable({}) | ||
// returns false | ||
isIterable({ A: '1', B: '2' }) | ||
isIterable([1,2,3]) | ||
// returns true | ||
``` | ||
sameType(*identityA*,*identityB*) | ||
containsKeys( *identity*, *keyList* ) | ||
``` | ||
Give an example | ||
const O = { | ||
propA : 'Test', | ||
propB: [1,2,3], | ||
propC: { | ||
name: 'mitsuketa', | ||
type : 'javascript' | ||
}, | ||
propD: 37 | ||
}; | ||
containsKeys( O, 'propC' ) | ||
containsKeys( O, ['propA','propB'] ) | ||
// returns true | ||
containsKeys( O, ['doesnt','exist'] ) | ||
// returns false | ||
``` | ||
getType(*identity*) | ||
sameStructure( *identityA*, *identityB* ) | ||
``` | ||
Give an example | ||
const objA = { A: '4', B: 0, C: 'for the win' }; | ||
const objB = { A: null, B: {}, C: ['hello','world'] }; | ||
sameStructure(objA,objB) | ||
// returns true | ||
sameStructure(objA,{ A: 'missing', C: 'B property'}) | ||
// returns false | ||
``` | ||
sameType( *identityA*, *identityB* ) | ||
``` | ||
sameType(10,8) | ||
// returns : 'number' | ||
sameType(10,'8') | ||
// returns : false | ||
sameType('hype','8') | ||
// returns : 'string' | ||
sameType({ print: 3 }, { print: 'foobar' }) | ||
// returns : 'object' | ||
sameType([], ['one',2,'III']) | ||
// returns : 'array' | ||
``` | ||
getType( *identity* ) | ||
``` | ||
getType(5) | ||
// returns: 'number' | ||
getType('7') | ||
getType('apple') | ||
// returns: 'string' | ||
getType(null) | ||
// returns: 'null' | ||
getType(void(0)) | ||
getType(undefined) | ||
// returns: 'undefined' | ||
getType([]) | ||
getType(['one','two','three']) | ||
getType(['hello',4,{}]) | ||
// returns: 'array' | ||
getType({}) | ||
getType({A: 'test', B: 'foobar'}) | ||
// returns: 'object' | ||
``` | ||
## Built With | ||
@@ -89,2 +299,2 @@ | ||
* Got my inspiration from lodash.js | ||
* Got my inspiration from lodash.js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12902
299