Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Apply method to all strings in an object in an object in an object...

Notifications You must be signed in to change notification settings

Teachiq/apply-to-nested-strings

 
 

Repository files navigation

Apply to nested strings

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

DISCLAIMER: This project has moved

This utility was originally maintained by previous employee and was forked so that Teachiq could keep control over it's source. This has since then be moved to https://github.com/Teachiq/utils, but is still references in some repositories.

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'
    }
  }]
}
*/

About

Apply method to all strings in an object in an object in an object...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • JavaScript 85.2%
  • TypeScript 14.8%