node-powertools
Advanced tools
Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "node-powertools", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Powerful assistive functions for Node and Browser environments.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -47,2 +47,3 @@ <p align="center"> | ||
### powertools.random(min, max, options) | ||
Generate a random number between two numbers `min` and `max`. You can use `options` to supply a sign or randomize the sign as well. If an array is supplied, a random element from the array is returned. | ||
@@ -58,2 +59,3 @@ ```js | ||
### powertools.arrayify(input) | ||
Transform the `input` into an array if it is not already. | ||
@@ -66,2 +68,3 @@ ```js | ||
### powertools.wait(time) | ||
Asynchronously wait for the specified `time` in milliseconds. | ||
@@ -73,2 +76,3 @@ ```js | ||
### powertools.poll(fn, options) | ||
Asynchronously wait for the specified `fn` to return `true`. You can use `options` to supply a polling interval and timeout in milliseconds. The promise **rejects** if the timeout is reached. | ||
@@ -83,2 +87,3 @@ ```js | ||
### powertools.escape(str) | ||
Add the escape character `\` before any character in `str` that needs to be escaped for a `RegExp`. | ||
@@ -93,2 +98,3 @@ ```js | ||
### powertools.regexify(str) | ||
Revive a `str` into a `RegExp`. Supports flags. Depending on how you want special characters to be treated, you can use `powertools.escape(str)` prior to using `powertools.regexify(str)`. | ||
@@ -106,2 +112,3 @@ ```js | ||
### powertools.timestamp(date, options) | ||
Convert a `date` to a timestamp in 3 formats: an ISO `string`, a UNIX `number`, or a plain-ol' JS `Date` (as specified in `options`). | ||
@@ -119,2 +126,14 @@ The first argument `date` can be a JS `Date`, a UNIX timestamp `number`, or a `string` that will be parsed by the `new Date()` method. | ||
### powertools.force(value, type, options) | ||
Intelligently converts a `value` to a `type` how JavaScript **should**. The acceptable types are `string`, `number`, `boolean`, `array`. | ||
```js | ||
powertools.force(undefined, 'string'); // Output: '' | ||
powertools.force('true', 'boolean'); // Output: true | ||
powertools.force('false', 'boolean'); // Output: false | ||
powertools.force('0', 'boolean'); // Output: false | ||
powertools.force('1,2,3', 'array'); // Output: ['1', '2', '3'] | ||
powertools.force('1,2,3', 'array', {force: 'number'}); // Output: [1, 2, 3] | ||
``` | ||
## Final Words | ||
@@ -121,0 +140,0 @@ If you are still having difficulty, we would love for you to post a question to [the Node Powertools issues page](https://github.com/itw-creative-works/node-powertools/issues). It is much easier to answer questions that include your code and relevant files! So if you can provide them, we'd be extremely grateful (and more likely to help you find the answer!) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23337
143
0