Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@balena/jellyfish-jellyscript

Package Overview
Dependencies
Maintainers
3
Versions
2521
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@balena/jellyfish-jellyscript

Jellyscript library for Jellyfish

  • 7.11.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by500%
Maintainers
3
Weekly downloads
 
Created
Source


npm version

Jellyscript

Write computed properties in JSON Schema using javascript expressions.
https://product-os.github.io/jellyfish-jellyscript



Installation

Install @balena/jellyfish-jellyscript by running:

npm install --save @balena/jellyfish-jellyscript

Usage

Jellyscript looks for the keyword $$formula in your schema and evaluates the expression it finds there. The full object data being evaluated is provided to the script execution scope as contract and the current field being evaluated is provided as input. A $$formula field must be an expression, and aliases and variables are not supported. Jellyscript supports all the functions provided by FormulaJS

Below is an example how to use this library:

import { Jellyscript } from '@balena/jellyfish-jellyscript';

const parser = new Jellyscript();

const schema = {
	type: 'object',
	properties: {
		number: {
			type: 'string',
			$$formula: 'SUM(contract.input, 10)',
		},
		lucky: {
			type: 'boolean',
			$$formula: 'contract.number === 13 ? true: false',
		},
		input: {
			type: 'number',
		},
	},
};

const data = {
	input: 3,
};

const result = parser.evaluateObject(schema, data);

console.log(result); // --> { lucky: true, number: 13, input: 3, }

FAQs

Package last updated on 28 Aug 2023

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc