-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Contra
committed
Jun 1, 2014
1 parent
16f8e3b
commit d594d74
Showing
6 changed files
with
59 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
language: node_js | ||
node_js: | ||
- 0.7 | ||
- 0.8 | ||
- 0.9 | ||
- "0.10" | ||
- "0.11" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,15 @@ | ||
require('coffee-script/register'); | ||
module.exports = require('./lib/main'); | ||
module.exports = function(chars) { | ||
if (typeof chars === 'string') { | ||
chars = chars.split('').map(function(str){ | ||
return str.charCodeAt(0); | ||
}); | ||
} | ||
|
||
if (!Array.isArray(chars)) { | ||
throw new Error('input must be a string or an array'); | ||
} | ||
|
||
return chars.reduce(function(prev, curr){ | ||
return ((prev << 5) + prev) + curr; | ||
}, 5381); | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,25 @@ | ||
{ | ||
"name":"djb2", | ||
"description":"djb2 hash in JS", | ||
"version":"0.0.1", | ||
"homepage":"http://github.com/wearefractal/djb2", | ||
"repository":"git://github.com/wearefractal/djb2.git", | ||
"author":"Fractal <contact@wearefractal.com> (http://wearefractal.com/)", | ||
"main":"./index.js", | ||
|
||
"dependencies":{ | ||
"coffee-script":"*" | ||
}, | ||
"devDependencies":{ | ||
"mocha":"*", | ||
"should":"*" | ||
}, | ||
"scripts":{ | ||
"test":"mocha --compilers coffee:coffee-script" | ||
}, | ||
"engines":{ | ||
"node":">= 0.4.0" | ||
}, | ||
"licenses":[ | ||
{ | ||
"type":"MIT", | ||
"url":"http://github.com/wearefractal/djb2/raw/master/LICENSE" | ||
} | ||
] | ||
"name": "djb2", | ||
"description": "djb2 hash in JS", | ||
"version": "0.0.2", | ||
"homepage": "http://github.com/wearefractal/djb2", | ||
"repository": "git://github.com/wearefractal/djb2.git", | ||
"author": "Fractal <contact@wearefractal.com> (http://wearefractal.com/)", | ||
"main": "./index.js", | ||
"devDependencies": { | ||
"mocha": "^1.20.0", | ||
"should": "^4.0.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha" | ||
}, | ||
"engines": { | ||
"node": ">= 0.4.0" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://github.com/wearefractal/djb2/raw/master/LICENSE" | ||
} | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
var djb2 = require('../'); | ||
var should = require('should'); | ||
require('mocha'); | ||
|
||
describe('djb2', function(){ | ||
describe('djb2(string)', function(){ | ||
it('should should work', function(done){ | ||
djb2("test").should.equal(2090756197); | ||
done(); | ||
}); | ||
}); | ||
|
||
describe('djb2(arr)', function(){ | ||
it('should should work', function(done){ | ||
djb2([101,102]).should.equal(5863344); | ||
done(); | ||
}); | ||
}); | ||
}); |