StdLib Node.js Bindings
StdLib Setup |
Node |
Python |
Ruby |
Web
Basic Node bindings for StdLib service accession (Node 4+).
Used to interface with services built using StdLib and
the StdLib Command Line Tools.
NEW: Promise support (for future async / await) added in 2.2.0
.
The lib
package is available on npm: lib and
operates as zero-dependency interface to run StdLib functions. This means that
you can utilize any service on StdLib without installing any additional
dependencies, and when you've deployed services to StdLib, you have a pre-built
Node.js SDK --- for example;
Callback Style
const lib = require('lib');
lib.yourUsername.hostStatus({name: 'Dolores Abernathy'}, (err, result) => {
});
Promise Style
const lib = require('lib');
lib.yourUsername.hostStatus({name: 'Dolores Abernathy'})
.then(result => )
.catch(err => );
To discover StdLib services, visit https://stdlib.com/search. To build a service,
get started with the StdLib CLI tools.
Installation
To install locally in a project (StdLib service or otherwise), use;
$ npm install lib --save
Usage
const lib = require('lib');
lib.stdlib.reflect(0, 1, {kwarg: 'value'}, (err, result) => {});
lib.stdlib.reflect['@dev'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib.stdlib.reflect['@release'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib.stdlib.reflect['@0.0.1'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib.stdlib.reflect.main(0, 1, {kwarg: 'value'}, (err, result) => {});
lib['stdlib.reflect'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib['stdlib.reflect[@dev]'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib['stdlib.reflect[@release]'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib['stdlib.reflect[@0.0.1]'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib['stdlib.reflect.main'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib['stdlib.reflect[@dev].main'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib['stdlib.reflect[@release].main'](0, 1, {kwarg: 'value'}, (err, result) => {});
lib['stdlib.reflect[@0.0.1].main'](0, 1, {kwarg: 'value'}, (err, result) => {});
Local Usage
To use StdLib services locally (from within a StdLib function), use the
"string composition" method and begin your service path with a period;
lib['.otherFunction']({key: 'X'}, (err, result) => {});
This functionality exists, so if needs be, you can directly interface with
other functions within a StdLib service when testing locally (i.e. MapReduce
usage). Please note that local functions always execute in the same context
and thread as the caller, meaning you will not get the scalability benefits
of calling the function remotely, however latency is significantly reduced.
Additional Information
To learn more about StdLib, visit stdlib.com or read the
StdLib CLI documentation on GitHub.
You can follow the development team on Twitter, @StdLibHQ
StdLib is © 2016 - 2017 Polybit Inc.