|
2 | 2 |
|
3 | 3 | ### Table of Contents |
4 | 4 |
|
5 | | -- [HelloObjectAsync](#helloobjectasync) |
6 | | - - [helloAsync](#helloasync) |
7 | | -- [HelloObject](#helloobject) |
8 | | - - [hello](#hello) |
9 | | -- [helloAsync](#helloasync-1) |
10 | | -- [hello](#hello-1) |
| 5 | +* [hello][1] |
| 6 | + * [Examples][2] |
| 7 | +* [helloAsync][3] |
| 8 | + * [Parameters][4] |
| 9 | + * [Examples][5] |
| 10 | +* [helloPromise][6] |
| 11 | + * [Parameters][7] |
| 12 | + * [Examples][8] |
| 13 | +* [HelloObject][9] |
| 14 | + * [Examples][10] |
| 15 | + * [hello][11] |
| 16 | + * [Examples][12] |
| 17 | +* [HelloObjectAsync][13] |
| 18 | + * [Examples][14] |
| 19 | + * [helloAsync][15] |
| 20 | + * [Parameters][16] |
| 21 | + * [Examples][17] |
11 | 22 |
|
12 | | -## HelloObjectAsync |
| 23 | +## hello |
13 | 24 |
|
14 | | -Asynchronous class, called HelloObjectAsync |
| 25 | +This is a synchronous standalone function that logs a string. |
15 | 26 |
|
16 | | -**Examples** |
| 27 | +### Examples |
17 | 28 |
|
18 | 29 | ```javascript |
19 | | -var module = require('index.js'); |
20 | | -var Obj = new module.HelloObjectAsync('greg'); |
| 30 | +const { hello } = require('@mapbox/node-cpp-skel'); |
| 31 | +const check = hello(); |
| 32 | +console.log(check); // => "hello world" |
21 | 33 | ``` |
22 | 34 |
|
23 | | -### helloAsync |
| 35 | +Returns **[string][18]** |
24 | 36 |
|
25 | | -Say hello while doing expensive work in threads |
| 37 | +## helloAsync |
26 | 38 |
|
27 | | -**Parameters** |
| 39 | +This is an asynchronous standalone function that logs a string. |
| 40 | + |
| 41 | +### Parameters |
28 | 42 |
|
29 | | -- `args` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** different ways to alter the string |
30 | | - - `args.louder` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** adds exclamation points to the string |
31 | | -- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** from whence the hello comes, returns a string |
| 43 | +* `args` **[Object][19]** different ways to alter the string |
32 | 44 |
|
33 | | -**Examples** |
| 45 | + * `args.louder` **[boolean][20]** adds exclamation points to the string |
| 46 | + * `args.buffer` **[boolean][20]** returns value as a node buffer rather than a string |
| 47 | +* `callback` **[Function][21]** from whence the hello comes, returns a string |
| 48 | + |
| 49 | +### Examples |
34 | 50 |
|
35 | 51 | ```javascript |
36 | | -var module = require('index.js'); |
37 | | -var Obj = new module.HelloObjectAsync('greg'); |
38 | | -Obj.helloAsync({ louder: true }, function(err, result) { |
| 52 | +const { helloAsync } = require('@mapbox/node-cpp-skel'); |
| 53 | +helloAsync({ louder: true }, function(err, result) { |
39 | 54 | if (err) throw err; |
40 | | - console.log(result); // => '...threads are busy async bees...hello greg!!!' |
| 55 | + console.log(result); // => "...threads are busy async bees...hello |
| 56 | +world!!!!" |
41 | 57 | }); |
42 | 58 | ``` |
43 | 59 |
|
44 | | -Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** |
| 60 | +Returns **[string][18]** |
| 61 | +
|
| 62 | +## helloPromise |
| 63 | +
|
| 64 | +This is a function that returns a promise. It multiplies a string N times. |
| 65 | +
|
| 66 | +### Parameters |
| 67 | +
|
| 68 | +* `options` **[Object][19]?** different ways to alter the string |
| 69 | +
|
| 70 | + * `options.phrase` **[string][18]** the string to multiply (optional, default `hello`) |
| 71 | + * `options.multiply` **[Number][22]** duplicate the string this number of times (optional, default `1`) |
| 72 | +
|
| 73 | +### Examples |
| 74 | +
|
| 75 | +```javascript |
| 76 | +const { helloPromise } = require('@mapbox/node-cpp-skel'); |
| 77 | +const result = await helloAsync({ phrase: 'Howdy', multiply: 3 }); |
| 78 | +console.log(result); // HowdyHowdyHowdy |
| 79 | +``` |
| 80 | +
|
| 81 | +Returns **[Promise][23]** |
45 | 82 |
|
46 | 83 | ## HelloObject |
47 | 84 |
|
48 | 85 | Synchronous class, called HelloObject |
49 | 86 |
|
50 | | -**Examples** |
| 87 | +### Examples |
51 | 88 |
|
52 | 89 | ```javascript |
53 | | -var module = require('index.js'); |
54 | | -var Obj = new module.HelloObject('greg'); |
| 90 | +const { HelloObject } = require('@mapbox/node-cpp-skel'); |
| 91 | +const Obj = new HelloObject('greg'); |
55 | 92 | ``` |
56 | 93 |
|
57 | 94 | ### hello |
58 | 95 |
|
59 | 96 | Say hello |
60 | 97 |
|
61 | | -**Examples** |
| 98 | +#### Examples |
62 | 99 |
|
63 | 100 | ```javascript |
64 | | -var x = Obj.hello(); |
| 101 | +const x = Obj.hello(); |
65 | 102 | console.log(x); // => '...initialized an object...hello greg' |
66 | 103 | ``` |
67 | 104 |
|
68 | | -Returns **[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** |
| 105 | +Returns **[String][18]** |
69 | 106 |
|
70 | | -## helloAsync |
| 107 | +## HelloObjectAsync |
71 | 108 |
|
72 | | -This is an asynchronous standalone function that logs a string. |
| 109 | +Asynchronous class, called HelloObjectAsync |
| 110 | +
|
| 111 | +### Examples |
| 112 | +
|
| 113 | +```javascript |
| 114 | +const { HelloObjectAsync } = require('@mapbox/node-cpp-skel'); |
| 115 | +const Obj = new module.HelloObjectAsync('greg'); |
| 116 | +``` |
73 | 117 |
|
74 | | -**Parameters** |
| 118 | +### helloAsync |
| 119 | +
|
| 120 | +Say hello while doing expensive work in threads |
| 121 | +
|
| 122 | +#### Parameters |
75 | 123 |
|
76 | | -- `args` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** different ways to alter the string |
77 | | - - `args.louder` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** adds exclamation points to the string |
78 | | -- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** from whence the hello comes, returns a string |
| 124 | +* `args` **[Object][19]** different ways to alter the string |
79 | 125 |
|
80 | | -**Examples** |
| 126 | + * `args.louder` **[boolean][20]** adds exclamation points to the string |
| 127 | + * `args.buffer` **[buffer][24]** returns object as a node buffer rather then string |
| 128 | +* `callback` **[Function][21]** from whence the hello comes, returns a string |
| 129 | +
|
| 130 | +#### Examples |
81 | 131 |
|
82 | 132 | ```javascript |
83 | | -var module = require('./path/to/lib/index.js'); |
84 | | -module.helloAsync({ louder: true }, function(err, result) { |
| 133 | +const { HelloObjectAsync } = require('@mapbox/node-cpp-skel'); |
| 134 | +const Obj = new HelloObjectAsync('greg'); |
| 135 | +Obj.helloAsync({ louder: true }, function(err, result) { |
85 | 136 | if (err) throw err; |
86 | | - console.log(result); // => "...threads are busy async bees...hello world!!!!" |
| 137 | + console.log(result); // => '...threads are busy async bees...hello greg!!!' |
87 | 138 | }); |
88 | 139 | ``` |
89 | 140 |
|
90 | | -Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** |
| 141 | +Returns **[String][18]** |
91 | 142 |
|
92 | | -## hello |
| 143 | +[1]: #hello |
93 | 144 |
|
94 | | -This is a synchronous standalone function that logs a string. |
| 145 | +[2]: #examples |
95 | 146 |
|
96 | | -**Examples** |
| 147 | +[3]: #helloasync |
97 | 148 |
|
98 | | -```javascript |
99 | | -var module = require('./path/to/lib/index.js'); |
100 | | -var check = module.hello(); |
101 | | -console.log(check); // => "hello world" |
102 | | -``` |
| 149 | +[4]: #parameters |
| 150 | +
|
| 151 | +[5]: #examples-1 |
| 152 | +
|
| 153 | +[6]: #hellopromise |
| 154 | +
|
| 155 | +[7]: #parameters-1 |
| 156 | +
|
| 157 | +[8]: #examples-2 |
| 158 | +
|
| 159 | +[9]: #helloobject |
| 160 | +
|
| 161 | +[10]: #examples-3 |
| 162 | +
|
| 163 | +[11]: #hello-1 |
| 164 | +
|
| 165 | +[12]: #examples-4 |
| 166 | +
|
| 167 | +[13]: #helloobjectasync |
| 168 | +
|
| 169 | +[14]: #examples-5 |
| 170 | +
|
| 171 | +[15]: #helloasync-1 |
| 172 | +
|
| 173 | +[16]: #parameters-2 |
| 174 | +
|
| 175 | +[17]: #examples-6 |
| 176 | +
|
| 177 | +[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String |
| 178 | +
|
| 179 | +[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object |
| 180 | +
|
| 181 | +[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean |
| 182 | +
|
| 183 | +[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function |
| 184 | +
|
| 185 | +[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number |
| 186 | +
|
| 187 | +[23]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise |
103 | 188 |
|
104 | | -Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** |
| 189 | +[24]: https://nodejs.org/api/buffer.html |
0 commit comments