@okiba/functions
v1.0.8
Published
Utility helpers for okiba.js
Downloads
4
Readme
Okiba / functions
A collection of contextless utility functions
__
Installation
npm i --save @okiba/functions
Or import it directly in the browser
<script type="module" src="https://unpkg.com/@okiba/functions/index.js"></script>
Usage
import functions from '@okiba/functions'
Untranspiled code 🛑
Okiba Core packages are not transpiled, so don't forget to transpile them with your favourite bundler. For example, using Babel with Webpack, you should prevent imports from okiba to be excluded from transpilation, like follows:
{
test: /\.js$/,
exclude: /node_modules\/(?!(@okiba)\/).*/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
debounce(callback, latency, timer)
Callback debounce helper. Returns a debounced version of provided callback
import {debounce} from '@okiba/functions'
const onResize = () => console.log('window resized')
window.addEventListener('resize', debounce(onResize, 300))
Arguments
+ callback
: function
The callback to be debounced
+ latency
: Number
The debounce delay time
+ timer
: Number
The timer id
Returns
function
The debounced version of original callback