JSPM

keyarray-set

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 422
  • Score
    100M100P100Q93735F
  • License MIT

set nested properties with key arrays

Package Exports

  • keyarray-set

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (keyarray-set) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

var set = require('keyarray-set')
var assert = require('assert')

var anObject = {
  a: {
    b: {}
  }
}

assert(set(anObject, ['a', 'b', 'c'], 'new value') === 'new value')

assert(anObject.a.b.hasOwnProperty('c') === true)

assert(anObject.a.b.c === 'new value')

assert.throws(function () {
  set(anObject, ['nonexistent', 'key'], 'another value')
}, TypeError)