inidot
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc.2 • Public • Published

Inidot banner

Inidot 📝

npmjs License Activity GitHub stars

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

Features

  • Lightweight 🪶
  • Minimalist ⚪ (but powerful)
  • TypeScript 🔷
  • Super-Fast
  • Suitable for large data 📃
  • Safe 🔒
  • Easy to use 🍞
  • ... and much more 🚀

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

Package Sidebar

Install

npm i inidot

Weekly Downloads

1

Version

1.0.0-rc.2

License

MIT

Unpacked Size

11.6 kB

Total Files

5

Last publish

Collaborators

  • inicontent