semicolon.js
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "semicolon.js", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Web development, redefined.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://semicolonjs.com", |
@@ -12,3 +12,3 @@ <h1 align="center"> | ||
<p align="center"> | ||
<a href="https://npmjs.com/package/semicolon.js"><img src="https://img.shields.io/badge/npm%20package-0.2.0-brightgreen.svg" alt="NPM"></a> | ||
<a href="https://npmjs.com/package/semicolon.js"><img src="https://badge.fury.io/js/semicolon.js.svg" alt="NPM"></a> | ||
<a href="https://gitter.im/devBanner/Lobby"><img src="http://badges.gitter.im/devBanner/Lobby.svg" alt="Gitter"></a> | ||
@@ -74,3 +74,32 @@ </p> | ||
##### Cryptography | ||
```javascript | ||
semicolon.mdSemicolon(); // 9eecb7db59d16c80417c72d1e1f4fbf1 | ||
semicolon.bcryptSemicolon(); // $2y$10$tvI086gYYhR6SfNO1sLAueVMFgjf.sXEcLJaDOpRjxJ2Z3FIpsqIu | ||
``` | ||
##### Different radices | ||
```javascript | ||
semicolon.binary(); // 111011 | ||
semicolon.octal(); // 73 | ||
semicolon.hex(); // 3b | ||
semicolon.base(4); // 323 | ||
semicolon.base(3); // 2012 | ||
``` | ||
##### Asynchronous Usage | ||
```javascript | ||
semicolon.async(function(err, semicolon) { | ||
// semicolon === ';' | ||
}); | ||
``` | ||
##### Filter, Map and Reduce | ||
```javascript | ||
semicolon.filter([';', true, ';']); // [';', ';'] | ||
semicolon.map([1, 2, 3]); // [';', ';', ';'] | ||
semicolon.reduce([1, 2, 3]); // ; | ||
``` | ||
## Download | ||
@@ -77,0 +106,0 @@ |
@@ -14,5 +14,21 @@ (function () { | ||
//todo: not sure how it works (Seriously?) | ||
semicolon.isSemicolon = function(a) { return a === semicolon(); }; | ||
semicolon.mdSemicolon = function() { return '9eecb7db59d16c80417c72d1e1f4fbf1'; }; | ||
semicolon.bcryptSemicolon = function() { return '$2y$10$tvI086gYYhR6SfNO1sLAueVMFgjf.sXEcLJaDOpRjxJ2Z3FIpsqIu'; }; | ||
semicolon.base = function(i) { return semicolon().charCodeAt(0).toString(i); }; | ||
semicolon.binary = function() { return semicolon.base(2); }; | ||
semicolon.octal = function() { return semicolon.base(8); }; | ||
semicolon.hex = function() { return semicolon.base(16); }; | ||
semicolon.async = function(callback) { | ||
process.nextTick(function() { | ||
callback(null, semicolon()); | ||
}); | ||
}; | ||
semicolon.map = function(array) { return array.map(semicolon); }; | ||
semicolon.filter = function(array) { return array.filter(semicolon.isSemicolon); }; | ||
semicolon.reduce = function(array) { return array.reduce(semicolon); }; | ||
@@ -19,0 +35,0 @@ if(typeof module !== 'undefined' && module.exports) { |
29
test.js
@@ -15,2 +15,29 @@ var assert = require('assert'); | ||
assert.equal(true, semicolon.isSemicolon(semicolon())); | ||
assert.equal(false, semicolon.isSemicolon('.')); | ||
assert.equal(false, semicolon.isSemicolon('.')); | ||
assert.equal('9eecb7db59d16c80417c72d1e1f4fbf1', semicolon.mdSemicolon(), 'The MD5 Hash of ";" should be "9eecb7db59d16c80417c72d1e1f4fbf1"'); | ||
assert.equal('$2y$10$tvI086gYYhR6SfNO1sLAueVMFgjf.sXEcLJaDOpRjxJ2Z3FIpsqIu', semicolon.bcryptSemicolon(), 'The Bcyrpt Hash of ";" should be "$2y$10$tvI086gYYhR6SfNO1sLAueVMFgjf.sXEcLJaDOpRjxJ2Z3FIpsqIu"'); | ||
assert.equal('111011', semicolon.binary(), 'The binary respresentation of ";" should be "111011"'); | ||
assert.equal('73', semicolon.octal(), 'The octal respresentation of ";" should be "73"'); | ||
assert.equal('3b', semicolon.hex(), 'The hexadecimal respresentation of ";" should be "3b"'); | ||
assert.equal('214', semicolon.base(5), 'A quinary semicolon should be 214'); | ||
assert.equal('323', semicolon.base(4), 'An quaternary semicolon should be 323'); | ||
assert.equal(JSON.stringify([';', ';']), JSON.stringify(semicolon.filter([';', true, ';']))); | ||
assert.equal(JSON.stringify([';', ';', ';']), JSON.stringify(semicolon.map([1, 2, 3]))); | ||
assert.equal(';', semicolon.reduce([1, 2, 3])); | ||
var asyncTests = 1; | ||
semicolon.async(function(err, semicolon) { | ||
assert.equal(err, null, 'Async should not result in an error.'); | ||
assert.equal(semicolon, ';', 'Async should pass ";" to callback.'); | ||
asyncTests--; | ||
}); | ||
setInterval(function() { | ||
if (!asyncTests) { | ||
process.exit(0); | ||
} | ||
}, 100); |
25590
62
119
7