README
Bunch of utilities
Bunch of function, which you are going to use everywhere. Why they are not in standard already?
How to use
Just add water import it your project!
import Utilities from 'bunch-of-utilities';
Methods
Agent:
Utilities.agent.request(string method, string url, [object options, [function callback]])
- implement a simple request. Options structure : {headers: {key: value, ...}, params: {key: value, ...}}
Utilities.agent.post(...) and Utilities.get(...)
- are shorthands for Utilities.request
Browser:
Utilities.browser.getBrowserName()
- returns name of the browser
Utilities.browser.getOS()
- returns name of the operation system
Data:
Utilities.data.getRandNum(number from, number to)
- returns a random integer in specified range (from 0 to 100 by default)
Utilities.data.getRandString(number length)
- returns a random string with specified length (10 characters by default)
Utilities.data.getRandBool()
- returns a random boolean value
Utilities.data.getSafeObject(object source)
- returns a copy of the source object, but without circular references
Url:
Utilities.url.getDomain(string url)
- returns domain of the url
Utilities.url.buildUrl(string base, object params)
- returns encoded url with get parameters
Function:
Utilities.function.defer(function source)
- execute function after the javascript engine executes the current call stack
Utilities.function.throttle(function source, number threshold)
- returns function, which cannot be executed more than once every period of threshold
Utilities.function.once(function source)
- returns function, which cannot be executed more than once
Building process
ES6 source files
|
|
webpack
|
+--- babel, eslint
|
ready to use
library
in umd format
Scripts
npm run build
- produces production version of your library under thelib
foldernpm run dev
- produces development version of your library and runs a watchernpm run test
- well ... it runs the tests :)npm run test:watch
- same as above but in a watch mode