@profiscience/knockout-contrib-utils-modify

[![Version][npm-version-shield]][npm] [![Dependency Status][david-dm-shield]][david-dm] [![Peer Dependency Status][david-dm-peer-shield]][david-dm-peer] [![Dev Dependency Status][david-dm-dev-shield]][david-dm-dev] [![Downloads][npm-stats-shield]][npm-sta

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@profiscience/knockout-contrib-utils-modify
44162.0.13 years ago4 years agoMinified + gzip package size for @profiscience/knockout-contrib-utils-modify in KB

Readme

utils.modify
!Versionnpm-version-shieldnpm !Dependency Statusdavid-dm-shielddavid-dm !Peer Dependency Statusdavid-dm-peer-shielddavid-dm-peer !Dev Dependency Statusdavid-dm-dev-shielddavid-dm-dev !Downloadsnpm-stats-shieldnpm-stats
This package is intended for consumption via the @profiscience/knockout-contrib metapackage

Modifies an observable using a transform function. Returns the new value.
Useful for wrapping general purpose utilities functions for Knockout observables.

Usage

import { modify } from '@profiscience/knockout-contrib'

const foobar = ko.observable('foobar')

function reverseString(str) {
  return str
    .split('')
    .reverse()
    .join('')
}

const ret = modify(foobar, reverseString)
;(foobar() === ret) === 'raboof'