I created a simple JS library with common functions:
!!window.JsUtils || (window.JsUtils = {});
JsUtils = (function () {
"use strict";
return {
randomHex: function (len) {
var maxlen = 8;
var min = Math.pow(16, Math.min(len, maxlen) - 1);
var max = Math.pow(16, Math.min(len, maxlen)) - 1;
var n = Math.floor(Math.random() * (max - min + 1)) + min;
var r = n.toString(16);
while (r.length < len) {
r = r + randHex(len - maxlen);
}
return r;
},
...
};
}());
I'd like to be able to install it trhough NPM, so that whenever I update the core I can update it on my projects. But I cannot find a linear guide on how to to this..
Till now I only understood you have to init an npm project
npm init
Fill the questions...and you have a package.json like this:
{
"name": "js-utils",
"version": "0.2.0",
"description": "Some common used JS functions",
"main": "js-utils.js",
"directories": {
"test": "test"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tonysamperi/js-utils.git"
},
"keywords": [
"js",
"utils",
"library",
"utility",
"utilities",
"javascript"
],
"author": "Tony Samperi <github@tonysamperi.it> (tonysamperi.github.io)",
"license": "MIT",
"bugs": {
"url": "https://github.com/tonysamperi/js-utils/issues"
},
"homepage": "https://github.com/tonysamperi/js-utils#readme"
}
But..would this work in npm?