New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jsomap

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsomap

A JavaScript Object mapping and templating language.

latest
Source
npmnpm
Version
0.3.0
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

JSOMap

JSOMap is yet another mapping and templating library for javascript objects.

Usage

Install it from the npm repository:

npm install --save jsomap

Then require it in your project:

const { JSOMap } = require('jsomap')

console.log(new JSOMap({ text: 'Hello, world!' }, { print: '[text]' }))

Selectors

Data from the input object can be referred to in macros and properties using square-bracket syntax. For example, if the input has a property text, it can be selected in a template like:

{ "print": "[text]" }

Macros

Templating functionality is provided by the JSOMacro class. The class is extensible by directly calling the JSOMap.addMacro() function.

Built-in Macros

Built-in macros are provided by class Macro, which class JSMacro extends. Documentation for all built-in macros are available can be found at Macro.

Extending

Function JSOMap.addMacro() can be used to directly add more macros at runtime. See JSOMap for examples.

Using

Macros are referred to by enclosing in curly braces:

{ "print": "{Date()}" }

Piping

Selectors and macros may have their output piped to other macros; this is called a 'pipe macro':

{ "print": "{[text] | Split(/ (.+))}" }

Pipe macros must have each selector or macro separated by a space, a pipe, and another space. This is enforced for readability; piped macros not coforming to this standard will break.

FAQs

Package last updated on 31 Aug 2020

Did you know?

Socket

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