stencila-js
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "stencila-js", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Stencila components for Javascript", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,26 +25,22 @@ ## `stencila/js` : Stencila for Javascript | ||
```js | ||
# Create a session | ||
// Create a session | ||
let session = new JsSession() | ||
# Evaluate an expression... | ||
// Evaluate an expression... | ||
session.execute('6*7') // { errors: {}, output: { type: 'int', format: 'text', value: '42' } } | ||
session.execute('6*7') # { errors: {}, output: { type: 'int', format: 'text', value: '42' } } | ||
// Output is the value of the last line | ||
session.execute('let x = 6\nx*7') // { errors: {}, output: { type: 'int', format: 'text', value: '42' } } | ||
# Output is the value of the last line, | ||
// If the last line is blank there is no output | ||
// (this is intended for code chunks that have side effects e.g. set up data) | ||
session.execute('let x = 6\nx*7\n\n') // { errors: {}, output: null } | ||
session.execute('let x = 6\nx*7') # { errors: {}, output: { type: 'int', format: 'text', value: '42' } } | ||
// You can specify input variables (that are local to that call) as a data pack | ||
session.execute('Math.PI*radius', {radius: pack(21.4)}) // { errors: {}, output: { type: 'flt', format: 'text', value: '67.23008278682157' } } | ||
session.execute('radius') // { errors: { '1': 'ReferenceError: radius is not defined' }, output: null } | ||
# If the last line is blank there is no output (this is intended for code chunks that have side effects e.g. set up data), | ||
session.execute('let x = 6\nx*7\n\n') # { errors: {}, output: null } | ||
# You can specify input variables (that are local to that call) as a data pack, | ||
session.execute('Math.PI*radius', {radius:pack(21.4)}) # { errors: {}, output: { type: 'flt', format: 'text', value: '67.23008278682157' } } | ||
session.execute('radius') # { errors: { '1': 'ReferenceError: radius is not defined' }, output: null } | ||
# You can also assign global variables which are available in subsequent calls, | ||
session.execute('globals.foo = "bar"\n\n') # { errors: {}, output: null } | ||
session.execute('foo') # { errors: {}, output: { type: 'str', format: 'text', value: 'bar' } } | ||
// You can also assign global variables which are available in subsequent calls | ||
session.execute('globals.foo = "bar"\n\n') // { errors: {}, output: null } | ||
session.execute('foo') // { errors: {}, output: { type: 'str', format: 'text', value: 'bar' } } | ||
``` | ||
@@ -51,0 +47,0 @@ |
@@ -28,23 +28,18 @@ const {pack, unpack} = require('./packing') | ||
* | ||
* # Evaluate an expression... | ||
* // Evaluate an expression... | ||
* session.execute('6*7') // { errors: {}, output: { type: 'int', format: 'text', value: '42' } } | ||
* | ||
* session.execute('6*7') # { errors: {}, output: { type: 'int', format: 'text', value: '42' } } | ||
* // Output is the value of the last line, | ||
* session.execute('let x = 6\nx*7') // { errors: {}, output: { type: 'int', format: 'text', value: '42' } } | ||
* | ||
* # Output is the value of the last line, | ||
* // If the last line is blank there is no output (this is intended for code chunks that have side effects e.g. set up data), | ||
* session.execute('let x = 6\nx*7\n\n') // { errors: {}, output: null } | ||
* | ||
* session.execute('let x = 6\nx*7') # { errors: {}, output: { type: 'int', format: 'text', value: '42' } } | ||
* // You can specify input variables (that are local to that call), | ||
* session.execute('Math.PI*radius', {radius:{type:'flt', format:'text', value: '21.4'}}) // { errors: {}, output: { type: 'flt', format: 'text', value: '67.23008278682157' } } | ||
* session.execute('radius') // { errors: { '1': 'ReferenceError: radius is not defined' }, output: null } | ||
* | ||
* # If the last line is blank there is no output (this is intended for code chunks that have side effects e.g. set up data), | ||
* | ||
* session.execute('let x = 6\nx*7\n\n') # { errors: {}, output: null } | ||
* | ||
* # You can specify input variables (that are local to that call), | ||
* | ||
* session.execute('Math.PI*radius', {radius:{type:'flt', format:'text', value: '21.4'}}) # { errors: {}, output: { type: 'flt', format: 'text', value: '67.23008278682157' } } | ||
* session.execute('radius') # { errors: { '1': 'ReferenceError: radius is not defined' }, output: null } | ||
* | ||
* # You can also assign global variables which are available in subsequent calls, | ||
* | ||
* session.execute('globals.foo = "bar"\n\n') # { errors: {}, output: null } | ||
* session.execute('foo') # { errors: {}, output: { type: 'str', format: 'text', value: 'bar' } } | ||
* // You can also assign global variables which are available in subsequent calls, | ||
* session.execute('globals.foo = "bar"\n\n') // { errors: {}, output: null } | ||
* session.execute('foo') // { errors: {}, output: { type: 'str', format: 'text', value: 'bar' } } | ||
*/ | ||
@@ -51,0 +46,0 @@ execute (code, inputs) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33855
355
72