Comparing version 1.3.0 to 1.3.1
@@ -74,3 +74,2 @@ # Introduction | ||
- [ ] If it does too much, ask for it to be broken up into smaller PRs. | ||
- [ ] Does it pass flake8? | ||
- [ ] Is it consistent? | ||
@@ -87,3 +86,3 @@ - [ ] Review the changes carefully, line by line. Make sure you understand every single part of every line. Learn whatever you do not know yet. | ||
- [ ] Do the tests pass for all of the following? If not, write a note in the PR, or fix them yourself. | ||
- [ ] Do the tests pass for all of the following? If not, write a note in the PR, or fix them yourself. [**Read about testing**](https://github.com/AndrewRedican/mitsuketa/wiki/How-to-Create-and-Run-Tests) | ||
@@ -123,3 +122,2 @@ - [ ] *Outlines have not been defined yet.* | ||
3. Slack | ||
4. Terminal Chat | ||
4. Terminal Chat |
var PackageDependents = require("package-dependents"); | ||
console.log('hello?'); | ||
PackageDependents("mitsuketa", function (err, packages) { | ||
@@ -5,0 +4,0 @@ console.log('packages: ',packages); |
@@ -366,5 +366,6 @@ /** | ||
switch(identityType){ | ||
case 'object' : newIdentity = {}; keyList.forEach(key => { newIdentity[key] = identity[key]; }); return newIdentity; break; | ||
case 'array' : newIdentity = keyList.map(key => { return identity[key]; }); return newIdentity; break; | ||
case 'object' : newIdentity = {}; keyList.forEach(key => { if(key in identity) newIdentity[key] = identity[key]; }); break; | ||
case 'array' : newIdentity = []; keyList.forEach(key => { if(key in identity) newIdentity.push(identity[key]); }); break; | ||
} | ||
return newIdentity; | ||
} | ||
@@ -375,3 +376,3 @@ | ||
* @param {Any} identity | ||
* @param {Any} keyList | ||
* @param {Array} keyList | ||
* @return {boolean} true || false | ||
@@ -385,3 +386,3 @@ */ | ||
for(var i = 0; i < keyCount; i++){ | ||
const key = keyList[i]; | ||
const key = '' + keyList[i]; | ||
if(identitykeys.indexOf(key) === -1){ result = false; break; } | ||
@@ -388,0 +389,0 @@ } |
@@ -1,5 +0,5 @@ | ||
1. What version of Go are you using (go version)? | ||
1. What version of Mitsuketa are you using (mitsuketa version)? | ||
2. What operating system and processor architecture are you using? | ||
3. What did you do? | ||
4. What did you expect to see? | ||
5. What did you see instead? | ||
5. What did you see instead? |
{ | ||
"name": "mitsuketa", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "A Javascript library that enables you to handle deeply nested objects easily.", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "index.js" | ||
"test": "node node_modules/mocha/bin/mocha test/*test.js", | ||
"dependents": "node dependents.js" | ||
}, | ||
@@ -29,4 +30,7 @@ "repository": { | ||
"devDependencies": { | ||
"chai": "^4.1.2", | ||
"json": "^9.0.6", | ||
"mocha": "^4.0.1", | ||
"package-dependents": "^1.2.10" | ||
} | ||
} |
# Mitsuketa ![Build Status](https://travis-ci.org/AndrewRedican/mitsuketa.svg?branch=master) | ||
A Javascript library that enables you to handle deeply nested objects easily. | ||
<p align="center"><img src=http://i.imgur.com/qF1mmY5.png><br /><br />A Javascript library that enables you to handle deeply nested objects easily.</p> | ||
@@ -5,0 +5,0 @@ ## Installation |
148
test/test.js
@@ -1,4 +0,37 @@ | ||
var assert = require('chai').assert; | ||
var mitsuketa = require('../index'); | ||
/** | ||
* Dependencies | ||
*/ | ||
var assert = require('chai').assert; | ||
/** | ||
* Test Subject | ||
*/ | ||
var mitsuketa = require('../index'); | ||
/** | ||
* Wrapper that returns a string representation of an object | ||
* @param {*} O | ||
*/ | ||
function stringify(O){ | ||
if([null,undefined].indexOf(O) > -1) return typeof O; | ||
return JSON.stringify(O).replace(/"/g, '\''); | ||
} | ||
/** | ||
* Returns a string that describes the operation | ||
* @param {number} n number of arguments in operation | ||
* @param {*} arg arguments of operation | ||
* @param {*} res expected results of opetation | ||
*/ | ||
function opDesciption(n,arg,res){ | ||
var str = 'correctly defines '; | ||
res = stringify(res); | ||
if(n === 1) return str + stringify(arg) + ' as ' + res; | ||
for(var i = 0; i < n; i++){ | ||
str += (stringify(arg[i]) + ( i + 1 === n ? '' : ' , ' )); | ||
} | ||
str += ' as ' + res; | ||
return str; | ||
} | ||
function add() { | ||
@@ -10,2 +43,8 @@ return Array.prototype.slice.call(arguments).reduce(function(prev, curr) { | ||
/** | ||
* | ||
* VERSION 1 FEATURES | ||
* | ||
*/ | ||
describe('getType(identity)', function() { | ||
@@ -25,3 +64,3 @@ var tests = [ | ||
tests.forEach(function(test) { | ||
it('correctly defines ' + test.args + " as '" + test.expected + "'", function() { | ||
it(opDesciption(1,test.args,test.expected), function() { | ||
var res = mitsuketa.getType(test.args); | ||
@@ -46,5 +85,4 @@ assert.equal(res, test.expected); | ||
]; | ||
tests.forEach(function(test) { | ||
it('correctly defines ' + test.args + " as '" + test.expected + "'", function() { | ||
it(opDesciption(2,test.args,test.expected), function() { | ||
var res = mitsuketa.sameType(test.args[0],test.args[1]); | ||
@@ -71,5 +109,4 @@ assert.equal(res, test.expected); | ||
]; | ||
tests.forEach(function(test) { | ||
it('correctly defines ' + test.args + " as '" + test.expected + "'", function() { | ||
it(opDesciption(2,test.args,test.expected), function() { | ||
var res = mitsuketa.sameStructure(test.args[0],test.args[1]); | ||
@@ -95,3 +132,2 @@ assert.equal(res, test.expected); | ||
l = {}; | ||
var tests = [ | ||
@@ -110,5 +146,4 @@ {args: [a,b], expected: true }, | ||
]; | ||
tests.forEach(function(test) { | ||
it('correctly defines ' + test.args + " as '" + test.expected + "'", function() { | ||
it(opDesciption(2,test.args,test.expected), function() { | ||
var res = mitsuketa.identical(test.args[0],test.args[1]); | ||
@@ -134,5 +169,4 @@ assert.equal(res, test.expected); | ||
]; | ||
tests.forEach(function(test) { | ||
it('correctly defines ' + test.args + " as '" + test.expected + "'", function() { | ||
it(opDesciption(1,test.args,test.expected), function() { | ||
var res = mitsuketa.isIterable(test.args); | ||
@@ -157,5 +191,4 @@ assert.equal(res, test.expected); | ||
]; | ||
tests.forEach(function(test) { | ||
it('correctly defines ' + test.args + " as '" + test.expected + "'", function() { | ||
it(opDesciption(2,test.args,test.expected), function() { | ||
var res = mitsuketa.containsKeys(test.args[0],test.args[1]); | ||
@@ -173,2 +206,3 @@ assert.equal(res, test.expected); | ||
{args: [Obj,['speed','acceleration']], expected: { speed : 5, acceleration : 3 } }, | ||
{args: [Arr,['super','extra']], expected: [] }, | ||
{args: [Arr,[1,2]], expected: ['super','extra'] }, | ||
@@ -180,9 +214,87 @@ {args: ['string',['speed','model']], expected: undefined }, | ||
]; | ||
tests.forEach(function(test) { | ||
it('correctly defines ' + test.args + " as '" + test.expected + "'", function() { | ||
it(opDesciption(2,test.args,test.expected), function() { | ||
var res = mitsuketa.trim(test.args[0],test.args[1]); | ||
assert.equal(res, test.expected); | ||
assert.equal(stringify(res), stringify(test.expected)); | ||
}); | ||
}); | ||
}); | ||
}); | ||
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' | ||
} | ||
} | ||
describe('locate(collection,identity)', function() { | ||
var tests = [ | ||
{args: [complexObject,2], expected: 'D.C.1.id' }, | ||
{args: [complexObject,{ id : 1 }], expected: 'D.C.0' }, | ||
{args: [complexObject,'7'], expected: false }, | ||
{args: [complexObject,'this is a description WORLD'], expected: 'D.C.1.description' }, | ||
{args: [complexObject,'x'], expected: 'C.OtherProperty.0' }, | ||
{args: [complexObject,{ type: 'test' }], expected: 'A.Example.DeeplyNested.AnotherProperty' } | ||
]; | ||
tests.forEach(function(test) { | ||
it(opDesciption(2,test.args,test.expected), function() { | ||
var res = mitsuketa.locate(test.args[0],test.args[1]); | ||
assert.equal(stringify(res), stringify(test.expected)); | ||
}); | ||
}); | ||
}); | ||
describe('deepGet(collection,identity)', function() { | ||
var tests = [ | ||
{args: [complexObject,2], expected: {name: 'John Teage', id: 2, description: 'this is a description WORLD'} }, | ||
{args: [complexObject,{ id : 1 }], expected: {name: 'Andrew Redican', id: 1, description: 'this is a description HELLO'} }, | ||
{args: [complexObject,'7'], expected: undefined }, | ||
{args: [complexObject,'this is a description WORLD'], expected: {name: 'John Teage', id: 2, description: 'this is a description WORLD'} }, | ||
{args: [complexObject,'x'], expected: ['x', 'y', 'z'] }, | ||
{args: [complexObject,{ type: 'test' }], expected: {type: 'test'} } | ||
]; | ||
tests.forEach(function(test) { | ||
it(opDesciption(2,test.args,test.expected), function() { | ||
var res = mitsuketa.deepGet(test.args[0],test.args[1]); | ||
assert.equal(stringify(res), stringify(test.expected)); | ||
}); | ||
}); | ||
}); | ||
/** | ||
* | ||
* VERSION 2 FEATURES | ||
* | ||
*/ |
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
50394
739
4