1.1.3 • Published 3 years ago
panin v1.1.3
Panin
A superset of function shortcuts. Built with TypeScript.
Note: This package is set of shortcuts, which makes calling JS's built-in features easier. WIP, still.
import { random, increment, chooseRandomFromArray, defaultVal, repeatEvery, log, map, push, parseJSON } from 'panin'
const awesomeArray = [{id: random(1, 99)}, {id: random(1, 99)}]; // This will give random id property between 1 and 99 to objects
console.log(awesomeArray);
For parsing a JSON file, after importing parseJSON function and declaring ArrayOfThings in JSON file, use:
import ArrayOfThings from '../arrayOfThings.json'
console.log(parseJSON(ArrayOfThings));
Instead of using timeouts in JS, you can use following:
import { repeatEvery } from 'panin'
function example() {
console.log("This function runs every 2 seconds!");
}
repeatEvery(2000, example);