@moreonion/js-utils
v0.1.2
Published
A collection of JavaScript utility functions for use in themes
Downloads
51
Readme
mo-js-utils
A collection of JavaScript utility functions for use in themes.
Utility functions
MO.utils.debounce(func, timeout = 100)
MO.utils.storageAvailable(type)
Development
Install nodejs
and yarn
, then install the needed dependencies:
apt install nodejs yarn
yarn install
Use the different yarn
scripts for the development workflow:
yarn run lint
yarn run test
yarn run dev
For building a releaseable artifact (library file) use:
yarn run dist
The development files are configured to be created under build/
, the
releaseable files are created under dist/
.
Advanced use
This project uses Parcel for bundling. For options run:
yarn run parcel --help
Setting the --global MO
option publishes the functions via a window.MO
global.
In order to build the JavaScript without [hash]
in the file name, just use
the main.js
as entrypoint (not the .html
file) when build
ing:
yarn run parcel build --global MO src/main.js
It has eslint
and babel
configured for the source and test files.
Tests are run via mocha
, assertions use Node's assert()
.
Mocking can be done with sinon
.