Comparing version 0.0.31 to 0.0.32
{ | ||
"name": "eden-hash", | ||
"description": "Eden Node JS Hash Methods", | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"author": { | ||
@@ -18,4 +18,4 @@ "name": "Christian Blanquera", | ||
"dependencies": { | ||
"eden-class": "0.0.31", | ||
"eden-array": "0.0.31" | ||
"eden-class": "0.0.32", | ||
"eden-array": "0.0.32" | ||
}, | ||
@@ -22,0 +22,0 @@ "main": "./hash.js", |
295
README.md
@@ -66,3 +66,3 @@ #Hash | ||
``` | ||
object concat(Object[,object..]); | ||
object concat(fname, lname ...); | ||
``` | ||
@@ -74,3 +74,4 @@ | ||
1. object[,object..] | ||
1. fname - first object (string | character | integer | date) | ||
2. lname - second object to be concat in first object (string | character | integer | date) | ||
@@ -86,3 +87,11 @@ #### Returns | ||
``` | ||
hash().concat(); | ||
var fname = 'Eliz'; | ||
var mi = 'B'; | ||
var lname = 'Bragais'; | ||
var age = 22; | ||
fname.concat(lname); | ||
fname.concat(' '.concat(mi.concat('.'.concat(' '.concat(lname))))); | ||
fname+' '.concat(mi+'.'+' '+lname); | ||
'Name:'+' '+fname+' '.concat(mi+'.'+' '+lname+'.'+' '+'Age:'+' '+age); | ||
``` | ||
@@ -93,3 +102,6 @@ | ||
``` | ||
RESULTS | ||
'ElizBragais' | ||
'Eliz B. Bragais' | ||
'Eliz B. Bragais' | ||
'Name: Eliz B. Bragais. Age: 22' | ||
``` | ||
@@ -104,3 +116,3 @@ | ||
``` | ||
bool each(Object, Function); | ||
bool each(key, value); | ||
``` | ||
@@ -112,5 +124,5 @@ | ||
1. object | ||
1. key - object | ||
2. function | ||
2. value - function | ||
@@ -126,3 +138,8 @@ #### Returns | ||
``` | ||
hash().each(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
hashed().each(hash, function(key, value); | ||
hash.hasOwnProperty(key); | ||
value; | ||
``` | ||
@@ -133,3 +150,4 @@ | ||
``` | ||
RESULTS | ||
true | ||
hash[key] | ||
``` | ||
@@ -144,3 +162,3 @@ | ||
``` | ||
number|false indexOf(Object, Mixed, Boolis.has, Object, Mixed); | ||
number|false indexOf(hash, 6, Boolis.has, Object, Mixed); | ||
``` | ||
@@ -152,7 +170,7 @@ | ||
1. object | ||
1. hash - object | ||
2. mixed | ||
2. 6 - mixed (if key value in object) | ||
3. boolis.has - = function(data, value) {Argument Testingis.argument()est(1, 'object')est(2, 'mixed');turn !this.each(data, function(key, test) {turn !(test === value);;*Returns the index of where inthe array the value is found | ||
3. boolis.has - = function(data, value) {Argument Testingis.argument()est(1, 'object')est(2, 'mixed');turn !this.each(data, function(key, test) {turn !(test === value);;*Returns the index of where in the array the value is found | ||
@@ -172,3 +190,6 @@ 4. object | ||
``` | ||
hash().indexOf(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
hash().indexOf(hash, 6); | ||
hash().indexOf(hash, 8); | ||
``` | ||
@@ -179,3 +200,4 @@ | ||
``` | ||
RESULTS | ||
'test1' | ||
false | ||
``` | ||
@@ -190,3 +212,3 @@ | ||
``` | ||
string implode(Object, String); | ||
string implode({test1:4,test2:6}, '-'); | ||
``` | ||
@@ -198,5 +220,5 @@ | ||
1. object | ||
1. {test1:4,test2:6} - object | ||
2. string | ||
2. '-' - string (object separator) | ||
@@ -212,3 +234,4 @@ #### Returns | ||
``` | ||
hash().implode(); | ||
hash().implode({test1:4,test2:6}, '-'); | ||
hash().implode({test1:4,test2:6}, '/'); | ||
``` | ||
@@ -219,3 +242,4 @@ | ||
``` | ||
RESULTS | ||
'4-6' | ||
'4/6' | ||
``` | ||
@@ -230,3 +254,3 @@ | ||
``` | ||
bool isEmpty(Object); | ||
bool isEmpty(hash); | ||
``` | ||
@@ -238,3 +262,3 @@ | ||
1. object | ||
1. hash - object (check if empty) | ||
@@ -250,3 +274,7 @@ #### Returns | ||
``` | ||
hash().isEmpty(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var test = {}; | ||
hashed().isEmpty(hash); | ||
hashed().isEmpty(test); | ||
``` | ||
@@ -257,3 +285,4 @@ | ||
``` | ||
RESULTS | ||
false | ||
true | ||
``` | ||
@@ -268,3 +297,3 @@ | ||
``` | ||
bool isHash(Object); | ||
bool isHash(item1); | ||
``` | ||
@@ -276,3 +305,3 @@ | ||
1. object | ||
1. item1 - object (chech if it is hsh) | ||
@@ -288,3 +317,41 @@ #### Returns | ||
``` | ||
hash().isHash(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var item1 = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var item2 = Date; | ||
var item3 = RegExp; | ||
var item4 = Math; | ||
var item5 = Array; | ||
var item6 = Function; | ||
var item7 = JSON; | ||
var item8 = String; | ||
var item9 = Boolean; | ||
var item10 = Number; | ||
var item11 = new Date(); | ||
var item12 = /[a-z]/; | ||
var item13 = [1, 2, 3, 4] | ||
var item14 = 'test'; | ||
var item15 = true; | ||
var item16 = 123; | ||
var item17 = function() {}; | ||
var item18 = null; | ||
hash().isHash(item1); | ||
hash().isHash(item2); | ||
hash().isHash(item3); | ||
hash().isHash(item4); | ||
hash().isHash(item5); | ||
hash().isHash(item6); | ||
hash().isHash(item7); | ||
hash().isHash(item8); | ||
hash().isHash(item9); | ||
hash().isHash(item10); | ||
hash().isHash(item11); | ||
hash().isHash(item12); | ||
hash().isHash(item13); | ||
hash().isHash(item14); | ||
hash().isHash(item15); | ||
hash().isHash(item16); | ||
hash().isHash(item17); | ||
hash().isHash(item18); | ||
``` | ||
@@ -295,3 +362,20 @@ | ||
``` | ||
RESULTS | ||
true | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
false | ||
``` | ||
@@ -306,3 +390,3 @@ | ||
``` | ||
array keys(Object); | ||
array keys(keys[0]); | ||
``` | ||
@@ -314,3 +398,3 @@ | ||
1. object | ||
1. keys[0] - object (key list) | ||
@@ -326,3 +410,9 @@ #### Returns | ||
``` | ||
hash().keys(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var keys = hashed().keys(hash); | ||
keys[0]; | ||
keys[1]; | ||
keys[3]; | ||
keys.length; | ||
``` | ||
@@ -333,3 +423,6 @@ | ||
``` | ||
RESULTS | ||
'test1' | ||
'test2' | ||
'test4' | ||
4 | ||
``` | ||
@@ -344,3 +437,3 @@ | ||
``` | ||
object ksort(Object); | ||
object ksort({test3:9,test2:7,test1:6}); | ||
``` | ||
@@ -352,3 +445,3 @@ | ||
1. object | ||
1. {test3:9,test2:7,test1:6} - object (ascending order by key) | ||
@@ -364,3 +457,6 @@ #### Returns | ||
``` | ||
hash().ksort(); | ||
var result = hashed().ksort({test3:9,test2:7,test1:6}); | ||
result = hashed().implode(result, '-'); | ||
hash().ksort(result); | ||
``` | ||
@@ -371,3 +467,3 @@ | ||
``` | ||
RESULTS | ||
'6-7-9' | ||
``` | ||
@@ -382,3 +478,3 @@ | ||
``` | ||
object krsort(Object); | ||
object krsort({test2:7,test3:9,test1:6}); | ||
``` | ||
@@ -390,3 +486,3 @@ | ||
1. object | ||
1. {test2:7,test3:9,test1:6} - object (descending order by key) | ||
@@ -402,3 +498,7 @@ #### Returns | ||
``` | ||
hash().krsort(); | ||
var result = hashed().krsort({test2:7,test3:9,test1:6});test1:6}); | ||
result = hashed().implode(result, '-'); | ||
hash().krsort(result); | ||
``` | ||
@@ -409,3 +509,3 @@ | ||
``` | ||
RESULTS | ||
'9-7-6' | ||
``` | ||
@@ -420,3 +520,3 @@ | ||
``` | ||
object map(Object, Function, [mixed[,mixed..]]); | ||
object map(hash, (key, value), hash.test2); | ||
``` | ||
@@ -428,7 +528,7 @@ | ||
1. object | ||
1. hash - object (locate the key value) | ||
2. function | ||
2. key, value - function | ||
3. [mixed[,mixed..]] | ||
3. hash.test2 - [mixed[,mixed..]] | ||
@@ -444,3 +544,13 @@ #### Returns | ||
``` | ||
hash().map(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
hashed().map(hash, function(key, value) { | ||
if(typeof value != 'number') { | ||
return value; | ||
} | ||
return value + 1; | ||
}); | ||
hash.test2; | ||
hash.test3; | ||
``` | ||
@@ -451,3 +561,4 @@ | ||
``` | ||
RESULTS | ||
8 | ||
10 | ||
``` | ||
@@ -462,3 +573,3 @@ | ||
``` | ||
object natksort(Object); | ||
object natksort({test2:9,test1:7}); | ||
``` | ||
@@ -470,3 +581,3 @@ | ||
1. object | ||
1. {test2:9,test1:7} - object (ascending order by key) | ||
@@ -482,3 +593,6 @@ #### Returns | ||
``` | ||
hash().natksort(); | ||
var result = hashed().natksort({test2:9,test1:7}); | ||
result = hashed().implode(result, '-'); | ||
hash().natksort(result); | ||
``` | ||
@@ -489,3 +603,3 @@ | ||
``` | ||
RESULTS | ||
'7-9' | ||
``` | ||
@@ -500,3 +614,3 @@ | ||
``` | ||
object natsort(Object); | ||
object natsort({test2:9,test1:7}); | ||
``` | ||
@@ -508,3 +622,3 @@ | ||
1. object | ||
1. {test2:9,test1:7} - object (ascending order array by key) | ||
@@ -520,3 +634,6 @@ #### Returns | ||
``` | ||
hash().natsort(); | ||
var result = hashed().natsort({test2:9,test1:7}); | ||
result = hashed().implode(result, '-'); | ||
hash().natsort(result); | ||
``` | ||
@@ -527,3 +644,3 @@ | ||
``` | ||
RESULTS | ||
'7-9' | ||
``` | ||
@@ -538,3 +655,3 @@ | ||
``` | ||
object reverse(Object); | ||
object reverse({test2:7,test3:9,test1:6}); | ||
``` | ||
@@ -546,3 +663,3 @@ | ||
1. object | ||
1. {test2:7,test3:9,test1:6} - object (descending order by value) | ||
@@ -558,3 +675,7 @@ #### Returns | ||
``` | ||
hash().reverse(); | ||
var result = hashed().reverse({test2:7,test3:9,test1:6});test1:6}); | ||
result = hashed().implode(result, '-'); | ||
hash().reverse(result); | ||
``` | ||
@@ -565,3 +686,3 @@ | ||
``` | ||
RESULTS | ||
'9-7-6' | ||
``` | ||
@@ -576,3 +697,3 @@ | ||
``` | ||
number size(Object); | ||
number size({test1:1,test:2}); | ||
``` | ||
@@ -584,3 +705,3 @@ | ||
1. object | ||
1. {test1:1,test:2} - object (count the given items) | ||
@@ -596,3 +717,3 @@ #### Returns | ||
``` | ||
hash().size(); | ||
hash().size({test1:1,test2:2}); | ||
``` | ||
@@ -603,3 +724,3 @@ | ||
``` | ||
RESULTS | ||
2 | ||
``` | ||
@@ -614,3 +735,3 @@ | ||
``` | ||
object sort(Object, [callback]); | ||
object sort({test3:4,test2:5,test1:1}, [callback]); | ||
``` | ||
@@ -622,3 +743,3 @@ | ||
1. object | ||
1. {test3:4,test2:5,test1:1} - object (ascending order by values) | ||
@@ -636,3 +757,6 @@ 2. [callback] | ||
``` | ||
hash().sort(); | ||
var result = hashed().sort({test3:3,test2:2,test1:1}); | ||
result = hashed().implode(result, '-'); | ||
hash().sort(result); | ||
``` | ||
@@ -643,3 +767,3 @@ | ||
``` | ||
RESULTS | ||
'1-2-3' | ||
``` | ||
@@ -654,3 +778,3 @@ | ||
``` | ||
string toQuery(Object); | ||
string toQuery({test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}); | ||
``` | ||
@@ -662,3 +786,3 @@ | ||
1. object | ||
1. {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]} - object | ||
@@ -674,3 +798,5 @@ #### Returns | ||
``` | ||
hash().toQuery(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
hash().toQuery(hash); | ||
``` | ||
@@ -681,3 +807,3 @@ | ||
``` | ||
RESULTS | ||
'test1=6&test2=7&test3=9&test4[0]=1&test4[1]=2&test4[2]=3&test4[3]=4&test4[4]=5' | ||
``` | ||
@@ -692,3 +818,3 @@ | ||
``` | ||
string toString(Object); | ||
string toString({test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}); | ||
``` | ||
@@ -700,3 +826,3 @@ | ||
1. object | ||
1. {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]} - object | ||
@@ -712,3 +838,5 @@ #### Returns | ||
``` | ||
hash().toString(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
hash().toString(hash); | ||
``` | ||
@@ -719,3 +847,3 @@ | ||
``` | ||
RESULTS | ||
'{"test1":6,"test2":7,"test3":9,"test4":[1,2,3,4,5]}' | ||
``` | ||
@@ -730,3 +858,3 @@ | ||
``` | ||
array values(Object); | ||
array values({test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}); | ||
``` | ||
@@ -738,3 +866,3 @@ | ||
1. object | ||
1. {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]} - object | ||
@@ -750,3 +878,10 @@ #### Returns | ||
``` | ||
hash().values(); | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var values = hashed().values(hash); | ||
values[0]; | ||
values[1]; | ||
values[2]; | ||
values[4]; | ||
values.length; | ||
``` | ||
@@ -757,3 +892,7 @@ | ||
``` | ||
RESULTS | ||
6 | ||
7 | ||
9 | ||
undefined | ||
4 | ||
``` |
@@ -15,2 +15,14 @@ var assert = require('assert'); | ||
it('should concats objects into one', function() { | ||
var fname = 'Eliz'; | ||
var mi = 'B'; | ||
var lname = 'Bragais'; | ||
var age = 22; | ||
assert.equal('ElizBragais', fname.concat(lname)); | ||
assert.equal('Eliz B. Bragais', fname.concat(' '.concat(mi.concat('.'.concat(' '.concat(lname)))))); | ||
assert.equal('Eliz B. Bragais', fname+' '.concat(mi+'.'+' '+lname)); | ||
assert.equal('Name: Eliz B. Bragais. Age: 22', 'Name:'+' '+fname+' '.concat(mi+'.'+' '+lname+'.'+' '+'Age:'+' '+age)); | ||
}); | ||
it('should test if hash has ', function() { | ||
@@ -23,2 +35,9 @@ var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
it('should returns true if the array has given value', function() { | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
assert.equal('test1', hashed().indexOf(hash, 6)); | ||
assert.equal(false, hashed().indexOf(hash, 8)); | ||
}); | ||
it('should test if is a hash', function() { | ||
@@ -67,3 +86,5 @@ var item1 = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var test = {}; | ||
assert.equal(false, hashed().isEmpty(hash)); | ||
assert.equal(true, hashed().isEmpty(test)); | ||
}); | ||
@@ -74,3 +95,5 @@ | ||
var keys = hashed().keys(hash); | ||
assert.equal('test1', keys[0]); | ||
assert.equal('test2', keys[1]); | ||
assert.equal('test4', keys[3]); | ||
assert.equal(4, keys.length); | ||
@@ -90,8 +113,9 @@ }); | ||
assert.equal(8, hash.test2); | ||
assert.equal(10, hash.test3); | ||
}); | ||
it('should change query to hash', function() { | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5], test5: '2013-04-03 12:12:12'}; | ||
assert.equal( | ||
'test1=6&test2=7&test3=9&test4[0]=1&test4[1]=2&test4[2]=3&test4[3]=4&test4[4]=5', | ||
'test1=6&test2=7&test3=9&test4[0]=1&test4[1]=2&test4[2]=3&test4[3]=4&test4[4]=5&test5=2013-04-03%2012%3A12%3A12', | ||
hashed().toQuery(hash)); | ||
@@ -110,3 +134,7 @@ }); | ||
var values = hashed().values(hash); | ||
assert.equal(6, values[0]); | ||
assert.equal(7, values[1]); | ||
assert.equal(9, values[2]); | ||
assert.equal(undefined, values[4]); | ||
assert.equal(4, values.length); | ||
@@ -126,2 +154,9 @@ }); | ||
}); | ||
it('should reverse sorts hash by key', function() { | ||
var result = hashed().krsort({test2:7,test3:9,test1:6}); | ||
result = hashed().implode(result, '-'); | ||
var test = hashed().implode({test3:9, test2:7, test1:6}, '-'); | ||
assert.equal(test, result); | ||
}); | ||
@@ -134,6 +169,20 @@ it('should natural key sort', function() { | ||
}); | ||
it('should sorts array by natural sort', function() { | ||
var result = hashed().natsort({test2:9,test1:7}); | ||
result = hashed().implode(result, '-'); | ||
var test = hashed().implode({test1:7, test2:9}, '-'); | ||
assert.equal(test, result); | ||
}); | ||
it('should reverse sorts a hash with respect to its keys', function() { | ||
var result = hashed().reverse({test2:7,test3:9,test1:6}); | ||
result = hashed().implode(result, '-'); | ||
var test = hashed().implode({test3:9, test2:7, test1:6}, '-'); | ||
assert.equal(test, result); | ||
}); | ||
it('should return the size', function() { | ||
var result = hashed().size({test1:1,test:2}); | ||
assert.equal('2', result); | ||
var result = hashed().size({test1:1,test2:2}); | ||
assert.equal(2, result); | ||
}); | ||
@@ -140,0 +189,0 @@ |
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
26085
536
827
+ Addededen-array@0.0.32(transitive)
+ Addededen-class@0.0.32(transitive)
- Removededen-array@0.0.31(transitive)
- Removededen-class@0.0.31(transitive)
Updatededen-array@0.0.32
Updatededen-class@0.0.32