Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/core/functools

core/functools

This module provides a bunch of functions and decorators to wrap another functions with adding some extra functionality. Also, see submodules of this module:

once

Decorator for Function.prototype.once. Returns a new function that allows to invoke the specified function only once.

import { once, debounce } from 'core/functools';

class Foo {
@once
bar() {
return Math.random();
}
}

const foo = new Foo();
console.log(foo.bar() === foo.bar());

debounce

Decorator for Function.prototype.debounce Returns a new function that allows to invoke a function, which it takes, only with the specified delay. The next invocation of the function will cancel the previous.

import { debounce } from 'core/functools';

class Foo {
@debounce(500)
bla() {
console.log('Bang!');
}
}

throttle

Decorator for Function.prototype.throttle. Returns a new function that allows to invoke a function, which it takes, not more often than the specified delay. The first invoking of a function will run immediately, but all rest invokes will be merged to one and executes after the specified delay.

import { throttle } from 'core/functools';

class Foo {
@throttle(500)
bla() {
console.log('Bang!');
}
}

Index

References

Re-exports InlineWarnOptions
Re-exports WarnAlternative
Re-exports WarnAlternativeOptions
Re-exports WarnContext
Re-exports WarnExprType
Re-exports WarnOptions
Re-exports WarnedFn
Re-exports constant
Re-exports debounce
Re-exports deprecate
Re-exports deprecated
Re-exports identity
Re-exports once
Re-exports throttle
Re-exports unimplement
Re-exports unimplemented
Re-exports warn
Re-exports warned