Skip to content

Commit

Permalink
Merge pull request #1 from 131/extends
Browse files Browse the repository at this point in the history
Extends
  • Loading branch information
131 committed Oct 1, 2015
2 parents d79a34a + cdd0880 commit 9b25208
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"url": "git@github.com:131/nyks.git"
},
"scripts": {
"test": " node node_modules/istanbul/lib/cli.js cover -x child_process/* -x process/* -x crypt/* -x path/* node_modules/mocha/bin/_mocha test/"
"test": " node node_modules/istanbul/lib/cli.js cover -x 'crypt/*' -x 'path/*' -x 'child_process/*' -x 'process/*' node_modules/mocha/bin/_mocha test/"
},
"readme": "# nyks toolkit\r\n\r\nExtend nodejs & javascript native API of missing functions.\r\n",
"readmeFilename": "README.md",
Expand Down
17 changes: 9 additions & 8 deletions string.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use strict';

module.exports = {
'chunk' : require('./string/chunk'),
'replaces' : require('./string/replaces'),
'rot13' : require('./string/rot13'),
'rreplaces': require('./string/rreplaces'),
'sprintf' : require('./string/sprintf'),
'stripEnd' : require('./string/stripEnd'),
'crc32' : require('./string/crc32'),
'stripStart' : require('./string/stripStart')
'chunk' : require('./string/chunk'),
'replaces' : require('./string/replaces'),
'rot13' : require('./string/rot13'),
'rreplaces' : require('./string/rreplaces'),
'sprintf' : require('./string/sprintf'),
'stripEnd' : require('./string/stripEnd'),
'crc32' : require('./string/crc32'),
'stripStart' : require('./string/stripStart'),
'hexToRgb' : require('./string/hexToRgb')
};

8 changes: 8 additions & 0 deletions string/hexToRgb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use strict";

var hexToRgb = function(str){
var hex = String(str).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
return (hex) ? hex.slice(1) : null;
};

module.exports = hexToRgb;
9 changes: 8 additions & 1 deletion test/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var rot13 = require('../string/rot13')
var crc32 = require('../string/crc32')
var chunk = require('../string/chunk')
var sprintf = require('../string/sprintf');
var hexToRgb = require('../string/hexToRgb');



Expand Down Expand Up @@ -79,7 +80,6 @@ describe("strings functions", function(){

it("should test sprinf", function(){


expect(sprintf('Hallo %s!', 'Welt')).to.be('Hallo Welt!');

});
Expand All @@ -89,4 +89,11 @@ describe("strings functions", function(){
it("should test crc32", function(){
expect(crc32("foobar")).to.be(-1628037227);
});

it("should test hexToRgb", function() {
expect(hexToRgb('#FF0000')).to.eql(['FF', '00', '00']);

expect(hexToRgb('not_an_hexa')).to.be(null);
});

});

0 comments on commit 9b25208

Please sign in to comment.