apply-to-nested-strings

1.0.3 • Public • Published

Apply to nested strings

Apply a string modifier to all strings within an object or array.

Installation

npm install apply-to-nested-strings

Usage

import applyToNestedStrings from 'apply-to-nested-strings'

let data = {
  name: 'Jane Doe',
  children: [
    name: 'Baby Doe',
    parents: {
      father: 'John Doe',
      mother: 'Jane Doe'
    }
  ]
}

data = applyToNestedStrings(data, (str) => {
  return str.toUpperCase()
})

/*
data = {
  name: 'JANE DOE',
  children: [{
    name: 'BABY DOE',
    parents: {
      father: 'JOHN DOE',
      mother: 'JANE DOE'
    }
  }]
}
*/

Package Sidebar

Install

npm i apply-to-nested-strings

Weekly Downloads

57

Version

1.0.3

License

MIT

Unpacked Size

3.54 kB

Total Files

3

Last publish

Collaborators

  • naartti