2.3.3 • Published 3 years ago

jalosi v2.3.3

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

Jalosi

npm version NPM Downloads Build Status Known Vulnerabilities GitHub license

Features

  • Seamlessly reuse code between the browser and node without fussing with module.exports
  • Hot-reload caching of scripts loaded from files
  • Native support for JSO files
  • Run untrusted code within a sandbox
  • Supports deferred loading
  • No dependencies, single-file implementation
  • Lightweight, less than 4k (uncompressed)

Installation

npm install jalosi

Example

var jalosi = require("jalosi");

var script = `

function ten() {
  return 10;
}

function twice(value) {
  return value + value;
}
`;

var { ten, twice } = jalosi.run(script);
console.log(twice(ten()));

API

jalosi.compile(scripts, imports, options);

Compiles an array of scripts together, but doesn't execute the code. (The scripts parameter can also be a single string.) If options.sandbox is truthy then only imports are made accesible to the script. Otherwise, everything from the global scope is included. (Excluding properties already defined by the imports object.) Returns an anonymous function.

jalosi.run(scripts, imports, options);

Invokes jalosi.compile, then runs the code. Returns whatever is returned by the combined scripts.

jalosi.defer(files, imports, options);

Same as jalosi.compile, but reads the scripts from an array of files instead. (The files parameter can also be a single string.) If options.path is set, all files will be loaded from the directory that it points to. Returns an anonymous function.

jalosi.load(files, imports, options);

Invokes jalosi.defer, then runs the code. Returns whatever is returned by the combined scripts.

jalosi(files, imports, options);

Alias for jalosi.load.

jalosi.cache;

Reference to Jalosi's file cache. (Useful for diagnostics.)

2.3.3

3 years ago

2.2.1

4 years ago

2.2.2

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.0

4 years ago

1.8.0

4 years ago

1.7.9

4 years ago

1.7.8

4 years ago

1.7.6

4 years ago

1.7.5

4 years ago

1.7.4

4 years ago

1.7.3

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.1

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.2.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.12

4 years ago

0.0.1

4 years ago

0.0.11

4 years ago

0.0.0

4 years ago