1.0.8 • Published 4 years ago

@okiba/functions v1.0.8

Weekly downloads
29
License
MIT
Repository
github
Last release
4 years ago

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

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago