added unit testing, and started implementing unit tests...phew
This commit is contained in:
21
node_modules/text-hex/LICENSE
generated
vendored
Normal file
21
node_modules/text-hex/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014-2015 Arnout Kazemier <opensource@3rd-Eden.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
20
node_modules/text-hex/README.md
generated
vendored
Normal file
20
node_modules/text-hex/README.md
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# text-hex
|
||||
|
||||
Transforms a given piece of text to a hex color.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install text-hex
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var hex = require('text-hex');
|
||||
console.log(hex('foo'));
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
24
node_modules/text-hex/index.js
generated
vendored
Normal file
24
node_modules/text-hex/index.js
generated
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
/***
|
||||
* Convert string to hex color.
|
||||
*
|
||||
* @param {String} str Text to hash and convert to hex.
|
||||
* @returns {String}
|
||||
* @api public
|
||||
*/
|
||||
module.exports = function hex(str) {
|
||||
for (
|
||||
var i = 0, hash = 0;
|
||||
i < str.length;
|
||||
hash = str.charCodeAt(i++) + ((hash << 5) - hash)
|
||||
);
|
||||
|
||||
var color = Math.floor(
|
||||
Math.abs(
|
||||
(Math.sin(hash) * 10000) % 1 * 16777216
|
||||
)
|
||||
).toString(16);
|
||||
|
||||
return '#' + Array(6 - color.length + 1).join('0') + color;
|
||||
};
|
57
node_modules/text-hex/package.json
generated
vendored
Normal file
57
node_modules/text-hex/package.json
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
{
|
||||
"_from": "text-hex@1.0.x",
|
||||
"_id": "text-hex@1.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==",
|
||||
"_location": "/text-hex",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "text-hex@1.0.x",
|
||||
"name": "text-hex",
|
||||
"escapedName": "text-hex",
|
||||
"rawSpec": "1.0.x",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.x"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/colorspace"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/text-hex/-/text-hex-1.0.0.tgz",
|
||||
"_shasum": "69dc9c1b17446ee79a92bf5b884bb4b9127506f5",
|
||||
"_spec": "text-hex@1.0.x",
|
||||
"_where": "/Users/josh.burman/Projects/braid/node_modules/colorspace",
|
||||
"author": {
|
||||
"name": "Arnout Kazemier"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/3rd-Eden/text-hex/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Generate a hex color from the given text",
|
||||
"devDependencies": {
|
||||
"assume": "2.1.x",
|
||||
"mocha": "5.2.x",
|
||||
"pre-commit": "1.2.x"
|
||||
},
|
||||
"homepage": "https://github.com/3rd-Eden/text-hex",
|
||||
"keywords": [
|
||||
"css",
|
||||
"color",
|
||||
"hex",
|
||||
"text"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "text-hex",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/3rd-Eden/text-hex.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --ui bdd test.js"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
11
node_modules/text-hex/test.js
generated
vendored
Normal file
11
node_modules/text-hex/test.js
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
describe('text-hex', function () {
|
||||
'use strict';
|
||||
|
||||
var assume = require('assume')
|
||||
, hex = require('./');
|
||||
|
||||
it('is a 6 digit hex', function () {
|
||||
assume(hex('a')).to.have.length(7); // including a #
|
||||
assume(hex('a244fdafadfa4 adfau8fa a u adf8a0')).to.have.length(7);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user