Skip to content

Latest commit

 

History

History
189 lines (121 loc) · 4.13 KB

API.md

File metadata and controls

189 lines (121 loc) · 4.13 KB

Table of Contents

hello

This is a synchronous standalone function that logs a string.

Examples

const { hello } = require('@mapbox/node-cpp-skel');
const check = hello();
console.log(check); // => "hello world"

Returns string

helloAsync

This is an asynchronous standalone function that logs a string.

Parameters

  • args Object different ways to alter the string

    • args.louder boolean adds exclamation points to the string
    • args.buffer boolean returns value as a node buffer rather than a string
  • callback Function from whence the hello comes, returns a string

Examples

const { helloAsync } = require('@mapbox/node-cpp-skel');
helloAsync({ louder: true }, function(err, result) {
  if (err) throw err;
  console.log(result); // => "...threads are busy async bees...hello
world!!!!"
});

Returns string

helloPromise

This is a function that returns a promise. It multiplies a string N times.

Parameters

  • options Object? different ways to alter the string

    • options.phrase string the string to multiply (optional, default hello)
    • options.multiply Number duplicate the string this number of times (optional, default 1)

Examples

const { helloPromise } = require('@mapbox/node-cpp-skel');
const result = await helloAsync({ phrase: 'Howdy', multiply: 3 });
console.log(result); // HowdyHowdyHowdy

Returns Promise

HelloObject

Synchronous class, called HelloObject

Examples

const { HelloObject } = require('@mapbox/node-cpp-skel');
const Obj = new HelloObject('greg');

hello

Say hello

Examples

const x = Obj.hello();
console.log(x); // => '...initialized an object...hello greg'

Returns String

HelloObjectAsync

Asynchronous class, called HelloObjectAsync

Examples

const { HelloObjectAsync } = require('@mapbox/node-cpp-skel');
const Obj = new module.HelloObjectAsync('greg');

helloAsync

Say hello while doing expensive work in threads

Parameters

  • args Object different ways to alter the string

    • args.louder boolean adds exclamation points to the string
    • args.buffer buffer returns object as a node buffer rather then string
  • callback Function from whence the hello comes, returns a string

Examples

const { HelloObjectAsync } = require('@mapbox/node-cpp-skel');
const Obj = new HelloObjectAsync('greg');
Obj.helloAsync({ louder: true }, function(err, result) {
  if (err) throw err;
  console.log(result); // => '...threads are busy async bees...hello greg!!!'
});

Returns String