API.md
February 22, 2022 ยท View on GitHub
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
-
argsObject different ways to alter the string -
callbackFunction 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
-
optionsObject? different ways to alter the string
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
-
argsObject different ways to alter the string -
callbackFunction 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