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

datascript-js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datascript-js

Simple runtime for DataScript.

latest
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Datascript (JS)

Create simple scripts for your application as data (for now, only in JSON).

Hello world:

["write", "Hello world!"]

Syntax:

Literal:

// Normal JSON literals
true
false
1.0
3.0
"Hey there"  // << Be careful with strings, they are special

Instruction:

// A function call is an array where the very first element is a string.
// and the rest are the parameters.

// The string is the function that gets called.
["<function_name>", ...params]

// What I meant by strings being special is that strings will turn arrays into function calls.

// This is a function call:
["wait", 1.0]

Block:

// A block is an array of instructions / literals

[
  ["write", "Hello world! x1"],
  ["write", "Hello world! x2"]
]

// The interpreter know that this is a block
// because the first element is an Array, an instruction.

// If the first element was a string, this would be
// treated as an instruction, right?
[
  "Hello World!", // This tried to call a function named "Hello World!" lmao
  ["write", "Hello world! x2"]
]

// If the array starts with the string "()"
// It'll be properly interpreted as a block
[
  "()",
  "Hello world!"   // No problem with having a string here, since it's the *second* item.
  ["write", "Hello world! x2"],
]

Keywords

datascript

FAQs

Package last updated on 16 Oct 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