Skip to content

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

License

Notifications You must be signed in to change notification settings

inicontent/inidot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published