All Projects → indix → javascript-easy-object

indix / javascript-easy-object

Licence: other
Now easily access or modify an object in javascript with javascript-easy-object.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to javascript-easy-object

obfc.js
Object Based Flow Charts(obfc): Draws SVG-based flow charts by creating objects in your web pages.
Stars: ✭ 19 (+46.15%)
Mutual labels:  object
DataTypes
Built-in data types
Stars: ✭ 34 (+161.54%)
Mutual labels:  object
Object.fromEntries
Official ES spec-compliant polyfill for Object.fromEntries
Stars: ✭ 33 (+153.85%)
Mutual labels:  object
php-helpers
An extensive set of PHP helper functions and classes.
Stars: ✭ 27 (+107.69%)
Mutual labels:  object
blender-xray
STALKER (aka xray-engine) import/export plugin for Blender 3D
Stars: ✭ 132 (+915.38%)
Mutual labels:  object
is-extendable
Answers the question: "can this value have keys?". Returns true if a value is any of the object types: array, regexp, plain object, function or date. Useful for determining if a value is an object that can be extended.
Stars: ✭ 19 (+46.15%)
Mutual labels:  object
derivejs
DeriveJS is a reactive ODM - Object Document Mapper - framework, a "wrapper" around a database, that removes all the hassle of data-persistence by handling it transparently in the background, in a DRY manner.
Stars: ✭ 54 (+315.38%)
Mutual labels:  object
copy-anything
An optimised way to copy'ing (cloning) an Object or Array. A small and simple integration
Stars: ✭ 19 (+46.15%)
Mutual labels:  object
SmartReplace
Unity plug-in for replacing scene objects while keeping their references.
Stars: ✭ 50 (+284.62%)
Mutual labels:  object
react-binary-tree
Binary Tree Traversal Visualisation
Stars: ✭ 25 (+92.31%)
Mutual labels:  traversal
SoftUni-Software-Engineering
SoftUni- Software Engineering
Stars: ✭ 47 (+261.54%)
Mutual labels:  object
object.omit
Return a copy of an object without the given keys.
Stars: ✭ 79 (+507.69%)
Mutual labels:  object
python-pyfields
Define fields in python classes. Easily.
Stars: ✭ 39 (+200%)
Mutual labels:  object
js-explorer
Find the method you need without digging through the docs, directly on the command line!
Stars: ✭ 287 (+2107.69%)
Mutual labels:  object
qverse
Traverse any data with DPML commands.
Stars: ✭ 25 (+92.31%)
Mutual labels:  object
obman
[cvpr19] Hands+Objects synthetic dataset, instructions to download and code to load the dataset
Stars: ✭ 120 (+823.08%)
Mutual labels:  object
timeline
Timeline - A photo organizer
Stars: ✭ 39 (+200%)
Mutual labels:  object
CarND-VehicleDetection
vehicle detection with deep learning
Stars: ✭ 34 (+161.54%)
Mutual labels:  object
Object.getOwnPropertyDescriptors
Spec-compliant shim for `Object.getOwnPropertyDescriptors` that works in ES5.
Stars: ✭ 19 (+46.15%)
Mutual labels:  object
obj-to-table
Create a table from an array of objects
Stars: ✭ 15 (+15.38%)
Mutual labels:  object

Javascript Easy Object (JEO)

A module for handling all the action related to object in one step with multi pattern traversal.

Traversal Patterns

  • Direct method : This is direct access to value through the path string separated by the delimitor during the JEO object initialization. Eg. For accessing the value e in the object { a: 'b', c: { d: 'e' } }, you can use path as a\\.c\\.d In above the delimitor is \\. which is the default value. You can change it by passing delimitor that you want during JEO object initialization.

  • Filter method : This method allows you to pick certain key or pattern in the object. Eg.

object :

{
  a: {
    v: 'a',
    b: {
      z: 'z1'
    },
    c: {
      z: 'z2'
    },
    d: {
      z: 'z3
    }
  }
}

path : a.[b,d].z

output: ['z1', 'z3']

  • One level skip method : This method allows you to skip a level and search for the pattern that you want. Eg.
object :

{
  a: {
    v: 'a',
    b: {
      z: 'z1'
    },
    c: {
      z: 'z2'
    },
    d: {
      z: 'z3
    }
  }
}

path : a.?.z

output : ['z1', 'z2', 'z3']

  • Any level skip method : This method allows you to pick the value for pattern without even knowing the path. Eg.
object :

{
  a: {
    v: 'a',
    b: {
      z: 'z1'
    },
    c: {
      z: 'z2'
    },
    d: {
      z: 'z3
    }
  }
}

path : *.z

output: ['z1', 'z2', 'z3', 'z4']

Usage

Above patterns can be composed with each other or can be used separately as per your need. With the above patterns you can do following actions :

     1. Get
     2. Put
     3. Delete
     4. Rename
     5. Get path

Get, put, delete method are well known actions. Rename action allows you to rename the key that is present in the object. Get-path allows you to specify any path traversal and it will return the path from root to the found element. Its return type is array of string(if more than one value found on traversal it will return all paths for those values).

Get has isSafe option which lets to return value or null safely instead of getting error on unknown path. Its default value is false. It is the third option in get function.

snippet :

import JEO from 'javascript-easy-object'

const jeo = new JEO('.') //delimitor value is optional. Default value is '\\.'
const values = jeo.get(object, path, true) // 3rd param is for isSafe mode
const modifiedObject = jeo.put(object, path, value)
const propertyDeletedObject = jeo.delete(object, path)
const renamedObject = jeo.rename(object, path, newName)
const paths = jeo.getPath(object, path)

Conclusion

More options in JEO and patterns for traversal will be released in future. If you're interested to contribute, please feel free to fork and send in a Pull Request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].