utilizes.toggle
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

toggle

Toggle property truthines. if the value is falsy set it to true, otherwise set it to false.

The third parameter is the values to toggle between. default to "[true, false]".

Return the toggled value.

Usage: toggle<I>(object, path: keyof object, values?: Array<I>): I | boolean

import { toggle } from 'utilizes.toggle'

const object = {
  foo: {
    bar: false
  },
  num: 0
}

toggle(object, `foo.bar`)
// Output: true
toggle(object, `num`, [1, 0]) // or "toggle(object, `num`, 1, 0)"
// Output: 1

This module exported from utilizes project.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i utilizes.toggle

      Weekly Downloads

      6

      Version

      1.0.9

      License

      MIT

      Unpacked Size

      57.2 kB

      Total Files

      5

      Last publish

      Collaborators

      • natqe3