@stdlib/datasets-cmudict 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CITATION.cff ADDED
@@ -0,0 +1,30 @@
1
+ cff-version: 1.2.0
2
+ title: stdlib
3
+ message: >-
4
+ If you use this software, please cite it using the
5
+ metadata from this file.
6
+
7
+ type: software
8
+
9
+ authors:
10
+ - name: The Stdlib Authors
11
+ url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
+
13
+ repository-code: https://github.com/stdlib-js/stdlib
14
+ url: https://stdlib.io
15
+
16
+ abstract: |
17
+ Standard library for JavaScript and Node.js.
18
+
19
+ keywords:
20
+ - JavaScript
21
+ - Node.js
22
+ - TypeScript
23
+ - standard library
24
+ - scientific computing
25
+ - numerical computing
26
+ - statistical computing
27
+
28
+ license: Apache-2.0 AND BSL-1.0
29
+
30
+ date-released: 2016
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2022 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 The Stdlib Authors.
package/README.md CHANGED
@@ -18,6 +18,17 @@ limitations under the License.
18
18
 
19
19
  -->
20
20
 
21
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
21
32
  # CMUdict
22
33
 
23
34
  [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
@@ -187,74 +198,7 @@ console.dir( cmudict( opts ) );
187
198
 
188
199
  <!-- /.examples -->
189
200
 
190
- * * *
191
-
192
- <section class="cli">
193
-
194
- ## CLI
195
-
196
- <section class="installation">
197
-
198
- ## Installation
199
-
200
- To use the module as a general utility, install the module globally
201
-
202
- ```bash
203
- npm install -g @stdlib/datasets-cmudict
204
- ```
205
-
206
- </section>
207
-
208
- <!-- CLI usage documentation. -->
209
-
210
- <section class="usage">
211
-
212
- ### Usage
213
-
214
- ```text
215
- Usage: cmudict [options]
216
-
217
- Options:
218
-
219
- -h, --help Print this message.
220
- -V, --version Print the package version.
221
- --data name Dataset name: dict, phones, symbols, vp.
222
- ```
223
-
224
- </section>
225
-
226
- <!-- /.usage -->
227
-
228
- <section class="notes">
229
-
230
- ### Notes
231
-
232
- - If the `--data` option is set to a supported dataset name, the CLI prints the contents of the respective dataset file as plain text. Otherwise, the output format is newline-delimited JSON ([NDJSON][ndjson]).
233
-
234
- </section>
235
-
236
- <!-- /.notes -->
237
-
238
- <section class="examples">
239
-
240
- ### Examples
241
-
242
- ```bash
243
- $ cmudict --data symbols
244
- AA
245
- AA0
246
- AA1
247
- AA2
248
- ...
249
- ```
250
-
251
- </section>
252
-
253
- <!-- /.examples -->
254
-
255
- </section>
256
201
 
257
- <!-- /.cli -->
258
202
 
259
203
  * * *
260
204
 
@@ -270,6 +214,11 @@ The data files (databases) and their contents are licensed under a [BSD-2-Clause
270
214
 
271
215
  <section class="related">
272
216
 
217
+ ## See Also
218
+
219
+ - <span class="package-name">[`@stdlib/datasets-cmudict-cli`][@stdlib/datasets-cmudict-cli]</span><span class="delimiter">: </span><span class="description">CLI package for use as a command-line utility.</span>
220
+
221
+
273
222
  </section>
274
223
 
275
224
  <!-- /.related -->
@@ -295,7 +244,7 @@ For more information on the project, filing bug reports and feature requests, an
295
244
 
296
245
  ## Copyright
297
246
 
298
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
247
+ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
299
248
 
300
249
  </section>
301
250
 
@@ -305,11 +254,13 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
305
254
 
306
255
  <section class="links">
307
256
 
257
+ [@stdlib/datasets-cmudict-cli]: https://www.npmjs.com/package/@stdlib/datasets-cmudict-cli
258
+
308
259
  [npm-image]: http://img.shields.io/npm/v/@stdlib/datasets-cmudict.svg
309
260
  [npm-url]: https://npmjs.org/package/@stdlib/datasets-cmudict
310
261
 
311
- [test-image]: https://github.com/stdlib-js/datasets-cmudict/actions/workflows/test.yml/badge.svg
312
- [test-url]: https://github.com/stdlib-js/datasets-cmudict/actions/workflows/test.yml
262
+ [test-image]: https://github.com/stdlib-js/datasets-cmudict/actions/workflows/test.yml/badge.svg?branch=v0.1.0
263
+ [test-url]: https://github.com/stdlib-js/datasets-cmudict/actions/workflows/test.yml?query=branch:v0.1.0
313
264
 
314
265
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/datasets-cmudict/main.svg
315
266
  [coverage-url]: https://codecov.io/github/stdlib-js/datasets-cmudict?branch=main
@@ -321,19 +272,24 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
321
272
 
322
273
  -->
323
274
 
275
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
276
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
277
+
278
+ [stdlib]: https://github.com/stdlib-js/stdlib
279
+
280
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
281
+
282
+ [cli-section]: https://github.com/stdlib-js/datasets-cmudict#cli
283
+ [cli-url]: https://github.com/stdlib-js/datasets-cmudict/tree/cli
284
+ [@stdlib/datasets-cmudict]: https://github.com/stdlib-js/datasets-cmudict/tree/main
285
+
324
286
  [umd]: https://github.com/umdjs/umd
325
287
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
326
288
 
327
289
  [deno-url]: https://github.com/stdlib-js/datasets-cmudict/tree/deno
328
290
  [umd-url]: https://github.com/stdlib-js/datasets-cmudict/tree/umd
329
291
  [esm-url]: https://github.com/stdlib-js/datasets-cmudict/tree/esm
330
-
331
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
332
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
333
-
334
- [stdlib]: https://github.com/stdlib-js/stdlib
335
-
336
- [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
292
+ [branches-url]: https://github.com/stdlib-js/datasets-cmudict/blob/main/branches.md
337
293
 
338
294
  [cmudict]: http://www.speech.cs.cmu.edu/cgi-bin/cmudict#about
339
295
 
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import cmudict from '../docs/types/index';
3
+ export = cmudict;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";var v=function(a,r){return function(){return r||a((r={exports:{}}).exports,r),r.exports}};var m=v(function(k,l){
2
+ var g=require('@stdlib/assert-has-own-property/dist'),q=require('@stdlib/assert-is-plain-object/dist'),w=require('@stdlib/assert-is-string/dist').isPrimitive,f=require('@stdlib/error-tools-fmtprodmsg/dist');function b(a,r){return q(r)?g(r,"data")&&(a.data=r.data,!w(a.data))?new TypeError(f('0M32W',"data",a.data)):null:new TypeError(f('0M32V',r));}l.exports=b
3
+ });var h=v(function(S,c){
4
+ var n=require("path").resolve,y=require('@stdlib/error-tools-fmtprodmsg/dist'),p=require('@stdlib/fs-read-json/dist').sync,_=require('@stdlib/assert-has-own-property/dist'),j=m(),d=["dict","phones","symbols","vp"],u={dict:n(__dirname,"..","data","dict.json"),phones:n(__dirname,"..","data","phones.json"),symbols:n(__dirname,"..","data","symbols.json"),vp:n(__dirname,"..","data","vp.json")},O={encoding:"utf8"};function E(a){var r,o,s,e,t,i;if(arguments.length>0){if(r={},o=j(r,a),o)throw o;if(r.data){if(!_(u,r.data))throw new RangeError(y('0M34S',"data",d.join('", "'),r.data));if(e=p(u[r.data],O),e instanceof Error)throw e;return e}}for(e={},i=0;i<d.length;i++){if(s=d[i],t=p(u[s]),t instanceof Error)throw t;e[s]=t}return e}c.exports=E
5
+ });var x=h();module.exports=x;
6
+ /** @license Apache-2.0 */
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/validate.js", "../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar isObject = require( '@stdlib/assert-is-plain-object' );\nvar isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Validates function options.\n*\n* @private\n* @param {Object} opts - destination object\n* @param {Options} options - function options\n* @param {string} [options.data] - dataset name\n* @returns {(Error|null)} null or an error object\n*\n* @example\n* var opts = {};\n* var options = {\n* 'data': 'phones'\n* };\n* var err = validate( opts, options );\n* if ( err ) {\n* throw err;\n* }\n*/\nfunction validate( opts, options ) {\n\tif ( !isObject( options ) ) {\n\t\treturn new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );\n\t}\n\tif ( hasOwnProp( options, 'data' ) ) {\n\t\topts.data = options.data;\n\t\tif ( !isString( opts.data ) ) {\n\t\t\treturn new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'data', opts.data ) );\n\t\t}\n\t}\n\treturn null;\n}\n\n\n// EXPORTS //\n\nmodule.exports = validate;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar resolve = require( 'path' ).resolve;\nvar format = require( '@stdlib/string-format' );\nvar readJSON = require( '@stdlib/fs-read-json' ).sync;\nvar hasOwnProp = require( '@stdlib/assert-has-own-property' );\nvar validate = require( './validate.js' );\n\n\n// VARIABLES //\n\nvar keys = [ 'dict', 'phones', 'symbols', 'vp' ];\nvar dataCMU = {\n\t'dict': resolve( __dirname, '..', 'data', 'dict.json' ),\n\t'phones': resolve( __dirname, '..', 'data', 'phones.json' ),\n\t'symbols': resolve( __dirname, '..', 'data', 'symbols.json' ),\n\t'vp': resolve( __dirname, '..', 'data', 'vp.json' )\n};\nvar fopts = {\n\t'encoding': 'utf8'\n};\n\n\n// MAIN //\n\n/**\n* Returns datasets from the Carnegie Mellon Pronouncing Dictionary (CMUdict).\n*\n* ## Notes\n*\n* - This function synchronously reads data from disk for each invocation. Such behavior is intentional and so is the avoidance of `require`. We assume that invocations are infrequent, and we want to avoid the `require` cache. This means that we allow data to be garbage collected and a user is responsible for explicitly caching data.\n*\n* @param {Options} [options] - options object\n* @param {string} [options.data] - dataset name\n* @throws {Error} unable to read data\n* @throws {TypeError} must provide an object\n* @throws {TypeError} must provide valid options\n* @throws {RangeError} must provide a recognized dataset name\n* @returns {(Object|StringArray)} dataset(s)\n*\n* @example\n* var data = cmudict();\n* // returns <Object>\n*\n* @example\n* var data = cmudict({\n*\t'data': 'symbols'\n* });\n* // returns <Array>\n*/\nfunction cmudict( options ) {\n\tvar opts;\n\tvar err;\n\tvar key;\n\tvar out;\n\tvar val;\n\tvar i;\n\n\tif ( arguments.length > 0 ) {\n\t\topts = {};\n\t\terr = validate( opts, options );\n\t\tif ( err ) {\n\t\t\tthrow err;\n\t\t}\n\t\tif ( opts.data ) {\n\t\t\tif ( !hasOwnProp( dataCMU, opts.data ) ) {\n\t\t\t\tthrow new RangeError( format( 'invalid option. `%s` option must be one of the following: \"%s\". Option: `%s`.', 'data', keys.join( '\", \"' ), opts.data ) );\n\t\t\t}\n\t\t\tout = readJSON( dataCMU[ opts.data ], fopts );\n\t\t\tif ( out instanceof Error ) {\n\t\t\t\tthrow out;\n\t\t\t}\n\t\t\treturn out;\n\t\t}\n\t}\n\tout = {};\n\tfor ( i = 0; i < keys.length; i++ ) {\n\t\tkey = keys[ i ];\n\t\tval = readJSON( dataCMU[ key ] );\n\t\tif ( val instanceof Error ) {\n\t\t\tthrow val;\n\t\t}\n\t\tout[ key ] = val;\n\t}\n\treturn out;\n}\n\n\n// EXPORTS //\n\nmodule.exports = cmudict;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* The Carnegie Mellon Pronouncing Dictionary (CMUdict).\n*\n* @module @stdlib/datasets-cmudict\n*\n* @example\n* var dict = require( '@stdlib/datasets-cmudict' );\n*\n* var data = dict();\n* // returns {...}\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAa,QAAS,iCAAkC,EACxDC,EAAW,QAAS,gCAAiC,EACrDC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAS,QAAS,uBAAwB,EAwB9C,SAASC,EAAUC,EAAMC,EAAU,CAClC,OAAML,EAAUK,CAAQ,EAGnBN,EAAYM,EAAS,MAAO,IAChCD,EAAK,KAAOC,EAAQ,KACf,CAACJ,EAAUG,EAAK,IAAK,GAClB,IAAI,UAAWF,EAAQ,8DAA+D,OAAQE,EAAK,IAAK,CAAE,EAG5G,KARC,IAAI,UAAWF,EAAQ,qEAAsEG,CAAQ,CAAE,CAShH,CAKAP,EAAO,QAAUK,ICjEjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,MAAO,EAAE,QAC5BC,EAAS,QAAS,uBAAwB,EAC1CC,EAAW,QAAS,sBAAuB,EAAE,KAC7CC,EAAa,QAAS,iCAAkC,EACxDC,EAAW,IAKXC,EAAO,CAAE,OAAQ,SAAU,UAAW,IAAK,EAC3CC,EAAU,CACb,KAAQN,EAAS,UAAW,KAAM,OAAQ,WAAY,EACtD,OAAUA,EAAS,UAAW,KAAM,OAAQ,aAAc,EAC1D,QAAWA,EAAS,UAAW,KAAM,OAAQ,cAAe,EAC5D,GAAMA,EAAS,UAAW,KAAM,OAAQ,SAAU,CACnD,EACIO,EAAQ,CACX,SAAY,MACb,EA8BA,SAASC,EAASC,EAAU,CAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACA,EAEJ,GAAK,UAAU,OAAS,EAAI,CAG3B,GAFAJ,EAAO,CAAC,EACRC,EAAMP,EAAUM,EAAMD,CAAQ,EACzBE,EACJ,MAAMA,EAEP,GAAKD,EAAK,KAAO,CAChB,GAAK,CAACP,EAAYG,EAASI,EAAK,IAAK,EACpC,MAAM,IAAI,WAAYT,EAAQ,gFAAiF,OAAQI,EAAK,KAAM,MAAO,EAAGK,EAAK,IAAK,CAAE,EAGzJ,GADAG,EAAMX,EAAUI,EAASI,EAAK,IAAK,EAAGH,CAAM,EACvCM,aAAe,MACnB,MAAMA,EAEP,OAAOA,CACR,CACD,CAEA,IADAA,EAAM,CAAC,EACD,EAAI,EAAG,EAAIR,EAAK,OAAQ,IAAM,CAGnC,GAFAO,EAAMP,EAAM,CAAE,EACdS,EAAMZ,EAAUI,EAASM,CAAI,CAAE,EAC1BE,aAAe,MACnB,MAAMA,EAEPD,EAAKD,CAAI,EAAIE,CACd,CACA,OAAOD,CACR,CAKAd,EAAO,QAAUS,IC5EjB,IAAIO,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_validate", "__commonJSMin", "exports", "module", "hasOwnProp", "isObject", "isString", "format", "validate", "opts", "options", "require_main", "__commonJSMin", "exports", "module", "resolve", "format", "readJSON", "hasOwnProp", "validate", "keys", "dataCMU", "fopts", "cmudict", "options", "opts", "err", "key", "out", "val", "main"]
7
+ }
@@ -16,7 +16,7 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /**
22
22
  * Interface defining function options.
package/lib/browser.js CHANGED
@@ -23,6 +23,7 @@
23
23
  var objectKeys = require( '@stdlib/utils-keys' );
24
24
  var copy = require( '@stdlib/utils-copy' );
25
25
  var hasOwnProp = require( '@stdlib/assert-has-own-property' );
26
+ var format = require( '@stdlib/string-format' );
26
27
  var validate = require( './validate.js' );
27
28
  var dataCMU = require( './data.js' );
28
29
 
@@ -61,7 +62,7 @@ function cmudict( options ) {
61
62
  }
62
63
  if ( opts.data ) {
63
64
  if ( !hasOwnProp( dataCMU, opts.data ) ) {
64
- throw new RangeError( 'invalid option. `data` option must be one of the following values: `'+objectKeys( dataCMU ).join(',')+'`. Option: `'+opts.data+'`.' );
65
+ throw new RangeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'data', objectKeys( dataCMU ).join( '", "' ), opts.data ) );
65
66
  }
66
67
  return copy( dataCMU[ opts.data ] );
67
68
  }
package/lib/data.js CHANGED
@@ -18,11 +18,21 @@
18
18
 
19
19
  'use strict';
20
20
 
21
+ // MODULES //
22
+
23
+ var dict = require( './../data/dict.json' );
24
+ var phones = require( './../data/phones.json' );
25
+ var symbols = require( './../data/symbols.json' );
26
+ var vp = require( './../data/vp.json' );
27
+
28
+
29
+ // MAIN //
30
+
21
31
  var data = {};
22
- data.dict = require( './../data/dict.json' );
23
- data.phones = require( './../data/phones.json' );
24
- data.symbols = require( './../data/symbols.json' );
25
- data.vp = require( './../data/vp.json' );
32
+ data.dict = dict;
33
+ data.phones = phones;
34
+ data.symbols = symbols;
35
+ data.vp = vp;
26
36
 
27
37
 
28
38
  // EXPORTS //
package/lib/index.js CHANGED
@@ -32,9 +32,9 @@
32
32
 
33
33
  // MODULES //
34
34
 
35
- var dict = require( './main.js' );
35
+ var main = require( './main.js' );
36
36
 
37
37
 
38
38
  // EXPORTS //
39
39
 
40
- module.exports = dict;
40
+ module.exports = main;
package/lib/main.js CHANGED
@@ -21,6 +21,7 @@
21
21
  // MODULES //
22
22
 
23
23
  var resolve = require( 'path' ).resolve;
24
+ var format = require( '@stdlib/string-format' );
24
25
  var readJSON = require( '@stdlib/fs-read-json' ).sync;
25
26
  var hasOwnProp = require( '@stdlib/assert-has-own-property' );
26
27
  var validate = require( './validate.js' );
@@ -49,7 +50,6 @@ var fopts = {
49
50
  *
50
51
  * - This function synchronously reads data from disk for each invocation. Such behavior is intentional and so is the avoidance of `require`. We assume that invocations are infrequent, and we want to avoid the `require` cache. This means that we allow data to be garbage collected and a user is responsible for explicitly caching data.
51
52
  *
52
- *
53
53
  * @param {Options} [options] - options object
54
54
  * @param {string} [options.data] - dataset name
55
55
  * @throws {Error} unable to read data
@@ -84,7 +84,7 @@ function cmudict( options ) {
84
84
  }
85
85
  if ( opts.data ) {
86
86
  if ( !hasOwnProp( dataCMU, opts.data ) ) {
87
- throw new RangeError( 'invalid option. `data` option must be one of the following values: `'+keys.join(',')+'`. Option: `'+opts.data+'`.' );
87
+ throw new RangeError( format( 'invalid option. `%s` option must be one of the following: "%s". Option: `%s`.', 'data', keys.join( '", "' ), opts.data ) );
88
88
  }
89
89
  out = readJSON( dataCMU[ opts.data ], fopts );
90
90
  if ( out instanceof Error ) {
package/lib/validate.js CHANGED
@@ -23,6 +23,7 @@
23
23
  var hasOwnProp = require( '@stdlib/assert-has-own-property' );
24
24
  var isObject = require( '@stdlib/assert-is-plain-object' );
25
25
  var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
26
+ var format = require( '@stdlib/string-format' );
26
27
 
27
28
 
28
29
  // MAIN //
@@ -48,12 +49,12 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive;
48
49
  */
49
50
  function validate( opts, options ) {
50
51
  if ( !isObject( options ) ) {
51
- return new TypeError( 'invalid argument. Options must be an object. Value: `' + options + '`.' );
52
+ return new TypeError( format( 'invalid argument. Options argument must be an object. Value: `%s`.', options ) );
52
53
  }
53
54
  if ( hasOwnProp( options, 'data' ) ) {
54
55
  opts.data = options.data;
55
56
  if ( !isString( opts.data ) ) {
56
- return new TypeError( 'invalid option. `data` option must be a string primitive. Option: `' + opts.data + '`.' );
57
+ return new TypeError( format( 'invalid option. `%s` option must be a string. Option: `%s`.', 'data', opts.data ) );
57
58
  }
58
59
  }
59
60
  return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/datasets-cmudict",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "description": "The Carnegie Mellon Pronouncing Dictionary (CMUdict).",
5
5
  "license": "Apache-2.0 and BSD",
6
6
  "author": {
@@ -13,9 +13,6 @@
13
13
  "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
14
  }
15
15
  ],
16
- "bin": {
17
- "cmudict": "./bin/cli"
18
- },
19
16
  "main": "./lib",
20
17
  "browser": "./lib/browser.js",
21
18
  "directories": {
@@ -43,29 +40,19 @@
43
40
  "url": "https://github.com/stdlib-js/stdlib/issues"
44
41
  },
45
42
  "dependencies": {
46
- "@stdlib/assert-has-own-property": "^0.0.x",
47
- "@stdlib/assert-is-plain-object": "^0.0.x",
48
- "@stdlib/assert-is-string": "^0.0.x",
49
- "@stdlib/cli-ctor": "^0.0.x",
50
- "@stdlib/fs-read-file": "^0.0.x",
51
- "@stdlib/fs-read-json": "^0.0.x",
52
- "@stdlib/streams-node-stdout": "^0.0.x",
53
- "@stdlib/utils-copy": "^0.0.x",
54
- "@stdlib/utils-index-of": "^0.0.x",
55
- "@stdlib/utils-keys": "^0.0.x"
43
+ "@stdlib/assert-has-own-property": "^0.1.0",
44
+ "@stdlib/assert-is-plain-object": "^0.1.0",
45
+ "@stdlib/assert-is-string": "^0.1.0",
46
+ "@stdlib/fs-read-json": "^0.1.0",
47
+ "@stdlib/string-format": "^0.1.0",
48
+ "@stdlib/utils-copy": "^0.1.0",
49
+ "@stdlib/utils-keys": "^0.1.0"
56
50
  },
57
51
  "devDependencies": {
58
- "@stdlib/assert-is-array": "^0.0.x",
59
- "@stdlib/assert-is-browser": "^0.0.x",
60
- "@stdlib/assert-is-string-array": "^0.0.x",
61
- "@stdlib/assert-is-windows": "^0.0.x",
62
- "@stdlib/bench": "^0.0.x",
63
- "@stdlib/process-exec-path": "^0.0.x",
64
- "@stdlib/regexp-eol": "^0.0.x",
65
52
  "proxyquire": "^2.0.0",
66
53
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
67
54
  "istanbul": "^0.4.1",
68
- "tap-spec": "5.x.x"
55
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
69
56
  },
70
57
  "engines": {
71
58
  "node": ">=0.10.0",
@@ -98,7 +85,7 @@
98
85
  "en"
99
86
  ],
100
87
  "funding": {
101
- "type": "patreon",
102
- "url": "https://www.patreon.com/athan"
88
+ "type": "opencollective",
89
+ "url": "https://opencollective.com/stdlib"
103
90
  }
104
91
  }
package/bin/cli DELETED
@@ -1,113 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @license Apache-2.0
5
- *
6
- * Copyright (c) 2018 The Stdlib Authors.
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- */
20
-
21
- 'use strict';
22
-
23
- // MODULES //
24
-
25
- var createReadStream = require( 'fs' ).createReadStream;
26
- var resolve = require( 'path' ).resolve;
27
- var getKeys = require( '@stdlib/utils-keys' );
28
- var indexOf = require( '@stdlib/utils-index-of' );
29
- var readFileSync = require( '@stdlib/fs-read-file' ).sync;
30
- var stdout = require( '@stdlib/streams-node-stdout' );
31
- var CLI = require( '@stdlib/cli-ctor' );
32
- var cmudict = require( './../lib' );
33
-
34
-
35
- // MAIN //
36
-
37
- /**
38
- * Main execution sequence.
39
- *
40
- * @private
41
- */
42
- function main() {
43
- var names;
44
- var flags;
45
- var opts;
46
- var cli;
47
-
48
- // Create a command-line interface:
49
- cli = new CLI({
50
- 'pkg': require( './../package.json' ),
51
- 'options': require( './../etc/cli_opts.json' ),
52
- 'help': readFileSync( resolve( __dirname, '..', 'docs', 'usage.txt' ), {
53
- 'encoding': 'utf8'
54
- })
55
- });
56
-
57
- // Get any provided command-line options:
58
- flags = cli.flags();
59
- if ( flags.help || flags.version ) {
60
- return;
61
- }
62
-
63
- opts = {};
64
- if ( flags.data ) {
65
- opts.data = flags.data;
66
- }
67
- names = [ 'dict', 'phones', 'symbols', 'vp' ];
68
- if ( indexOf( names, opts.data ) === -1 ) {
69
- ndjson();
70
- } else {
71
- txt( opts.data );
72
- }
73
-
74
- /**
75
- * Prints data as newline-delimited JSON (ndjson).
76
- *
77
- * @private
78
- */
79
- function ndjson() {
80
- var data;
81
- var keys;
82
- var i;
83
- data = cmudict( opts );
84
- keys = getKeys( data );
85
- for ( i = 0; i < keys.length; i++ ) {
86
- console.log( JSON.stringify( data[ keys[i] ] ) ); // eslint-disable-line no-console
87
- }
88
- }
89
-
90
- /**
91
- * Prints data to `stdout`.
92
- *
93
- * @private
94
- * @param {string} filename - file name (no extension)
95
- */
96
- function txt( filename ) {
97
- var fpath = resolve( __dirname, '../data/'+filename+'.txt' );
98
- createReadStream( fpath )
99
- .pipe( stdout )
100
- .on( 'close', onClose );
101
- }
102
-
103
- /**
104
- * Exits the CLI.
105
- *
106
- * @private
107
- */
108
- function onClose() {
109
- cli.close( 0 );
110
- }
111
- }
112
-
113
- main();
package/docs/repl.txt DELETED
@@ -1,39 +0,0 @@
1
-
2
- {{alias}}( [options] )
3
- Returns datasets from the Carnegie Mellon Pronouncing Dictionary (CMUdict).
4
-
5
- Data includes the following:
6
-
7
- - dict: the main pronouncing dictionary
8
- - phones: manners of articulation for each sound
9
- - symbols: complete list of ARPABET symbols used by the dictionary
10
- - vp: verbal pronunciations of punctuation marks
11
-
12
- Parameters
13
- ----------
14
- options: Object (optional)
15
- Function options.
16
-
17
- options.data: string (optional)
18
- Dataset name.
19
-
20
- Returns
21
- -------
22
- out: Object|Array
23
- CMUdict dataset.
24
-
25
- Examples
26
- --------
27
- > var data = {{alias}}();
28
- > var dict = data.dict
29
- {...}
30
- > var phones = data.phones
31
- {...}
32
- > var symbols = data.symbols
33
- [...]
34
- > var vp = data.vp
35
- {...}
36
-
37
- See Also
38
- --------
39
-
@@ -1,49 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2020 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import cmudict = require( './index' );
20
-
21
-
22
- // TESTS //
23
-
24
- // The function returns an object or array of strings...
25
- {
26
- cmudict(); // $ExpectType Object | String[]
27
- }
28
-
29
- // The compiler throws an error if the function is provided a first argument which is not an object...
30
- {
31
- cmudict( 'abc' ); // $ExpectError
32
- cmudict( false ); // $ExpectError
33
- cmudict( true ); // $ExpectError
34
- cmudict( null ); // $ExpectError
35
- cmudict( 123 ); // $ExpectError
36
- cmudict( [] ); // $ExpectError
37
- cmudict( ( x: number ): number => x ); // $ExpectError
38
- }
39
-
40
- // The compiler throws an error if the function is provided a `data` option which is not a recognized dataset name...
41
- {
42
- cmudict( { 'data': 'abc' } ); // $ExpectError
43
- cmudict( { 'data': 123 } ); // $ExpectError
44
- cmudict( { 'data': true } ); // $ExpectError
45
- cmudict( { 'data': false } ); // $ExpectError
46
- cmudict( { 'data': [] } ); // $ExpectError
47
- cmudict( { 'data': {} } ); // $ExpectError
48
- cmudict( { 'data': ( x: number ): number => x } ); // $ExpectError
49
- }
package/docs/usage.txt DELETED
@@ -1,8 +0,0 @@
1
-
2
- Usage: cmudict [options]
3
-
4
- Options:
5
-
6
- -h, --help Print this message.
7
- -V, --version Print the package version.
8
- --data name Dataset name: dict, phones, symbols, vp.
package/etc/cli_opts.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "string": [
3
- "data"
4
- ],
5
- "boolean": [
6
- "help",
7
- "version"
8
- ],
9
- "alias": {
10
- "help": [
11
- "h"
12
- ],
13
- "version": [
14
- "V"
15
- ]
16
- }
17
- }