Comparing version 0.0.1 to 0.0.2
10
hash.js
@@ -1,2 +0,2 @@ | ||
module.exports = require('eden-class').define(function(prototype) { | ||
module.exports = require('eden-class').extend(function(prototype) { | ||
/* Require | ||
@@ -390,3 +390,3 @@ -------------------------------*/ | ||
var value, query = []; | ||
var value, self = this, query = []; | ||
@@ -399,3 +399,3 @@ this.each(data, function(key, value) { | ||
if(value instanceof Array) { | ||
value = this.toQuery(value, key); | ||
value = self.toQuery(value, key); | ||
query.push(value); | ||
@@ -405,4 +405,4 @@ return; | ||
if(typeof value == 'object') { | ||
value = this.toQuery(value, key); | ||
if(typeof value === 'object') { | ||
value = self.toQuery(value, key); | ||
query.push(value); | ||
@@ -409,0 +409,0 @@ return; |
{ | ||
"name": "eden-hash", | ||
"description": "Eden Node JS Hash Methods", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"author": { | ||
@@ -19,3 +19,3 @@ "name": "Christian Blanquera", | ||
"eden-class": "0.0.1", | ||
"eden-array": "0.0.1" | ||
"eden-array": "0.0.2" | ||
}, | ||
@@ -22,0 +22,0 @@ "main": "./hash.js", |
var assert = require('assert'); | ||
var hash = require('../hash'); | ||
var hashed = require('../hash'); | ||
@@ -9,3 +9,3 @@ describe('Hash Test Suite', function() { | ||
hash().each(hash, function(key, value) { | ||
hashed().each(hash, function(key, value) { | ||
assert.equal(true, hash.hasOwnProperty(key)); | ||
@@ -19,4 +19,4 @@ assert.equal(hash[key], value); | ||
assert.equal(true, hash().has(hash, 6)); | ||
assert.equal(false, hash().has(hash, 8)); | ||
assert.equal(true, hashed().has(hash, 6)); | ||
assert.equal(false, hashed().has(hash, 8)); | ||
}); | ||
@@ -26,3 +26,3 @@ | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
assert.equal(false, hash().isEmpty(hash)); | ||
assert.equal(false, hashed().isEmpty(hash)); | ||
}); | ||
@@ -32,5 +32,5 @@ | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var keys = hash().keys(hash); | ||
var keys = hashed().keys(hash); | ||
assert.equal('test2', keys[1]); | ||
this.assertCount(4, keys); | ||
assert.equal(4, keys.length); | ||
}); | ||
@@ -40,3 +40,3 @@ | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
hash().map(hash, function(key, value) { | ||
hashed().map(hash, function(key, value) { | ||
if(typeof value != 'number') { | ||
@@ -56,3 +56,3 @@ return value; | ||
'test1=6&test2=7&test3=9&test4[0]=1&test4[1]=2&test4[2]=3&test4[3]=4&test4[4]=5', | ||
hash().toQuery(hash)); | ||
hashed().toQuery(hash)); | ||
}); | ||
@@ -64,3 +64,3 @@ | ||
'{"test1":6,"test2":7,"test3":9,"test4":[1,2,3,4,5]}', | ||
hash().toString(hash)); | ||
hashed().toString(hash)); | ||
}); | ||
@@ -70,9 +70,9 @@ | ||
var hash = {test1: 6, test2: 7, test3: 9, test4: [1,2,3,4,5]}; | ||
var values = hash().values(hash); | ||
var values = hashed().values(hash); | ||
assert.equal(7, values[1]); | ||
this.assertCount(4, values); | ||
assert.equal(4, values.length); | ||
}); | ||
it('should implode hash to string', function() { | ||
var result = hash().implode({test1:4,test2:6}, '-'); | ||
var result = hashed().implode({test1:4,test2:6}, '-'); | ||
assert.equal('4-6', result); | ||
@@ -82,5 +82,5 @@ }); | ||
it('should key sort', function() { | ||
var result = hash().ksort({test3:9,test2:7,test1:6}); | ||
result = hash().implode(result, '-'); | ||
var test = hash().implode({test1:6,test2:7, test3:9}, '-'); | ||
var result = hashed().ksort({test3:9,test2:7,test1:6}); | ||
result = hashed().implode(result, '-'); | ||
var test = hashed().implode({test1:6,test2:7, test3:9}, '-'); | ||
assert.equal(test, result); | ||
@@ -90,5 +90,5 @@ }); | ||
it('should natural key sort', function() { | ||
var result = hash().natksort({test2:9,test1:7}); | ||
result = hash().implode(result, '-'); | ||
var test = hash().implode({test1:7, test2:9}, '-'); | ||
var result = hashed().natksort({test2:9,test1:7}); | ||
result = hashed().implode(result, '-'); | ||
var test = hashed().implode({test1:7, test2:9}, '-'); | ||
assert.equal(test, result); | ||
@@ -98,3 +98,3 @@ }); | ||
it('should return the size', function() { | ||
var result = hash().size({test1:1,test:2}); | ||
var result = hashed().size({test1:1,test:2}); | ||
assert.equal('2', result); | ||
@@ -104,5 +104,5 @@ }); | ||
it('should sort the hash by values', function() { | ||
var result = hash().sort({test3:3,test2:2,test1:1}); | ||
result = hash().implode(result, '-'); | ||
var test = hash().implode({test1:1,test2:2,test3:3}, '-'); | ||
var result = hashed().sort({test3:3,test2:2,test1:1}); | ||
result = hashed().implode(result, '-'); | ||
var test = hashed().implode({test1:1,test2:2,test3:3}, '-'); | ||
assert.equal(test, result); | ||
@@ -109,0 +109,0 @@ }); |
11583
6
+ Addededen-array@0.0.2(transitive)
- Removededen-array@0.0.1(transitive)
Updatededen-array@0.0.2