1.0.0-rc.2 • Published 3 months ago

inidot v1.0.0-rc.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Inidot banner

Inidot :pencil:

npmjs License Activity GitHub stars

Get, set, or delete a property from a nested object using a dot path :fire:

Features

  • Lightweight 🪶
  • Minimalist :white_circle: (but powerful)
  • TypeScript :large_blue_diamond:
  • Super-Fast :zap:
  • Suitable for large data :page_with_curl:
  • Safe :lock:
  • Easy to use :bread:
  • ... and much more :rocket:

Usage

import Inidot from "inidot";
// or
import {
  toDotNotation,
  getProperty,
  setProperty,
  deleteProperty,
  hasProperty
} from "inidot";

const myObj = {
  name: "Jo,hn",
  age: 21,
  address: {
    city: "New York",
    zip: 65221,
  },
  hobbies: ["Reading", "Tra[veling", ["test", "test2", { test: true }]],
};

// Get Property by path
Inidot.getProperty(myObj, "address.city");
// New York

// Get Unexisted Property by path
Inidot.getProperty(myObj, "address.country");
// undefined

// Define a default value
Inidot.getProperty(myObj, "address.city", "Morocco");
// Morocco

Selector Examples

- `obj.value` => `['obj', 'value']`
- `obj.ary.0.value` => `['obj', 'ary', '0', 'value']`
- `obj.ary.0.va\\.lue` => `['obj', 'ary', '0', 'va.lue']`
- `obj.ary.*.value` => `['obj', 'ary', '*', 'value']`

If you like Inidot, please sponsor: GitHub Sponsors || Paypal.

Install

<npm|pnpm|yarn> install inidot

License

MIT