dot-get-set

1.2.1 • Public • Published

dot-get-set

Flexible filesystem accessor for text and JSON

Feature Built With
Concurrent file access proper-lockfile
File glob node-glob
Fuzzy immutable "dot" accessor camel-dot-prop-immutable

Example

File Contents
hello.txt world
lorem/ipsum/dolor.json { sit: "amet" }
test.js See below
import getSet from "dot-get-set"
;(async () => {
  let config = await getSet(__dirname, "**/*")

  config.get("hello")
  // "world"

  config.get("lorem.ipsum.dolor.sit")
  // "amet"

  config = config.set("hello", "universe")
  // "universe" > hello.txt

  config.get("hello")
  // "universe"

  config = config.set("lorem.ipsum.dolor", { sed: "do" })
  // { sed: "do" } > lorem/ipsum/dolor.json

  config.get("lorem.ipsum.dolor")
  // { sed: "do" }
})()

Because the operation is immutable, config needs to be reassigned when mutated.

Package Sidebar

Install

npm i dot-get-set

Weekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

23.2 kB

Total Files

12

Last publish

Collaborators

  • winton