Socket
Socket
Sign inDemoInstall

@jsonlang/object

Package Overview
Dependencies
8
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @jsonlang/object

JsonLang Extension for (Key-Value pair) Object/Map Operations


Version published
Maintainers
1
Install size
575 kB
Created

Readme

Source

👋 JsonLang/Object

JsonLang Logo




It is JsonLang Plugin/Extension for Object operations.

npm version install size npm downloads Vulnerabilities Maintenance Build Programming Language License FOSSA Status Github Sponsor





Installation

npm install @jsonlang/core @jsonlang/object

🎉 Usage

import { JsonLang } from '@jsonlang/core';
import { ObjectRules } from '@jsonlang/object';

const jsonLang = new JsonLang();

jsonLang.import(ObjectRules);



⚒️ Rules


For more Info and examples


  • Get [In Progress]

    • Input[]: Array (Size: 3) {path: string, defaultValue?: any, data:{}}.
    • Output: Any.
    • Description: It accepts two inputs, the 1st one (required) is a path to get the Data, and the 2nd one (optional) is a default value of the path is not found. the path must follow the dotted style var1.var2 for nested fields and brackets with number for arrays var1.var2[3].var3
  • Set [In Progress]

    • Input[]: Array (Size: 3) {path: string, value: any, data:{}}.
    • Output: Any.
    • Description: It accepts two inputs. The 1st one (required) is a path to update/mutate the Data, and the 2nd one is the value to set. the path must follow the dotted style var1.var2 for nested fields and brackets with number for arrays var1.var2[3].var3. If the path does not exist, the Set Rule will create it.
  • Update [In Progress]

    • Input[]: Array (Size: 3) {path: string, value: any, data:{}}.
    • Output: Any.
    • Description: It accepts two inputs. The 1st one (required) is a path to update/mutate the Data, and the 2nd one is the value to update. the path must follow the dotted style var1.var2 for nested fields and brackets with number for arrays var1.var2[3].var3. If the path does not exist, the Update rule won't do anything.
  • Delete [In Progress]

    • Input[]: Array (Size: 2) {path: string, data:{}}.
    • Output: Any.
    • Description: It accepts two inputs, a path to mutate the Data by deleting a field in the request path. the path must follow the dotted style var1.var2 for nested fields and brackets with number for arrays var1.var2[3].var3. If the path does not exist, the Delete rule won't do anything.
  • More...


💻Examples


import { JsonLang } from '@jsonlang/core';
import { ObjectRules } from '@jsonlang/object';

const jsonLang = new JsonLang();

jsonLang.import(ObjectRules);

jsonLang.execute(
  { $R: 'Get', $I: ['data.test', null, { $R: 'Data', $I: ['External'] }] },
  { data: { id: '1', test: 100 } },
  { sync: true }
); // 100



🔌 Compatibility


This library uses Array.map and Array.reduce, so it's not exactly Internet Explorer 8 friendly.


📜 License


JsonLang/Object is MIT licensed

Keywords

FAQs

Last updated on 18 Sep 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc