fix node 6 tests, reduce npm package size

This commit is contained in:
Moos 2019-05-29 22:51:32 -07:00
parent 8a3d7efa14
commit da44ac7c35
6 changed files with 53 additions and 66 deletions

View File

@ -1,6 +1,7 @@
language: node_js language: node_js
node_js: node_js:
- '12'
- '11'
- '10' - '10'
- '8' - '8'
- '6' - '6'
- '4'

View File

@ -12,6 +12,14 @@ Version 1.x is a major update with no direct dependence on [natural's](https://g
:zap: v2.x can work in browsers -- see below for example. :zap: v2.x can work in browsers -- see below for example.
## Installation
npm install -g wordpos
To run test: (or just: npm test)
npm install -g mocha
mocha test
## Quick usage ## Quick usage
@ -35,7 +43,7 @@ Command-line: (see [CLI](bin) for full command list)
```bash ```bash
$ wordpos def git $ wordpos def git
git git
n: a person who is deemed to be despicable or contemptible; "only a rotter would do that"; "kill the rat"; "throw the bum out"; "you cowardly little pukes!"; "the British call a contemptible person a `git'" n: a person who is deemed to be despicable or contemptible; "only a rotter would do that"; "kill the rat"; "throw the bum out"; "you cowardly little pukes!"; "the British call a contemptible person a 'git'"
$ wordpos def git | wordpos get --adj $ wordpos def git | wordpos get --adj
# Adjective 6: # Adjective 6:
@ -47,16 +55,8 @@ little
British British
``` ```
## Installation
npm install -g wordpos ## Options
To run test: (or just: npm test)
npm install -g mocha
mocha test
### Options
```js ```js
WordPOS.defaults = { WordPOS.defaults = {
@ -298,7 +298,7 @@ Note that callback receives full arguments (including profile, if enabled), whil
v2.0 introduces the capability of running wordpos in the browser. The dictionary files are optimized for fast access (lookup by lemma), but they must be fetched, parsed and loaded into browser memory. The files are loaded on-demand (unless the option `preload: true` is given). v2.0 introduces the capability of running wordpos in the browser. The dictionary files are optimized for fast access (lookup by lemma), but they must be fetched, parsed and loaded into browser memory. The files are loaded on-demand (unless the option `preload: true` is given).
The dict files can be served locally or from CDN (coming soon). Include the following scripts in your `index.html`: The dict files can be served locally or from CDN (see [samples/cdn](samples/cdn/).). Include the following scripts in your `index.html`:
```html ```html
<script src="wordpos/dist/wordpos.min.js"></script> <script src="wordpos/dist/wordpos.min.js"></script>
<script> <script>
@ -316,7 +316,19 @@ The dict files can be served locally or from CDN (coming soon). Include the fol
``` ```
Above assumes wordpos is installed to the directory `./wordpos`. `./wordpos/dict` holds the index and data WordNet files generated for the web in a postinstall script. Above assumes wordpos is installed to the directory `./wordpos`. `./wordpos/dict` holds the index and data WordNet files generated for the web in a postinstall script.
See [samples/self-hosted](samples/self-hosted/main.js). See [samples/self-hosted](samples/self-hosted/).
To run the samples locally, install [parcel](https://github.com/parcel-bundler/parcel) if you don't already have it (`npm i -g parcel`), then:
```bash
$ npm run start-self
Server running at http://localhost:1234
...
$ npm run start-cdn
Server running at http://localhost:1234
...
```
and open your browser to that url.
## Fast Index (node) ## Fast Index (node)
@ -344,6 +356,7 @@ See [bench/README](bench).
**2.0.0** **2.0.0**
- Support for running wordpos in browser (no breaking change for node environment) - Support for running wordpos in browser (no breaking change for node environment)
- Dropped support for node 4.x.
1.2.0 1.2.0
- Fix `new Buffer()` deprecation warning. - Fix `new Buffer()` deprecation warning.

57
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "wordpos", "name": "wordpos",
"version": "2.0.0-alpha", "version": "2.0.0-beta",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -1251,11 +1251,6 @@
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=",
"dev": true "dev": true
}, },
"chownr": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz",
"integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE="
},
"color-convert": { "color-convert": {
"version": "1.9.3", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
@ -1540,29 +1535,12 @@
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=" "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0="
}, },
"minipass": {
"version": "2.3.4",
"resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.4.tgz",
"integrity": "sha512-mlouk1OHlaUE8Odt1drMtG1bAJA4ZA6B/ehysgV0LUIrDHdKgo1KorZq3pK0b/7Z7LJIQ12MNM6aC+Tn6lUZ5w==",
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
}
},
"minizlib": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz",
"integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==",
"requires": {
"minipass": "^2.2.1"
}
},
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
@ -1771,7 +1749,8 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
"dev": true
}, },
"semver": { "semver": {
"version": "5.6.0", "version": "5.6.0",
@ -1825,18 +1804,6 @@
"mz": "^2.4.0" "mz": "^2.4.0"
} }
}, },
"tar": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/tar/-/tar-3.2.1.tgz",
"integrity": "sha512-ZSzds1E0IqutvMU8HxjMaU8eB7urw2fGwTq88ukDOVuUIh0656l7/P7LiVPxhO5kS4flcRJQk8USG+cghQbTUQ==",
"requires": {
"chownr": "^1.0.1",
"minipass": "^2.0.2",
"minizlib": "^1.0.3",
"mkdirp": "^0.5.0",
"yallist": "^3.0.2"
}
},
"thenify": { "thenify": {
"version": "3.3.0", "version": "3.3.0",
"resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz", "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz",
@ -1899,23 +1866,15 @@
"dev": true "dev": true
}, },
"wordnet-db": { "wordnet-db": {
"version": "3.1.6", "version": "3.1.11",
"resolved": "https://registry.npmjs.org/wordnet-db/-/wordnet-db-3.1.6.tgz", "resolved": "https://registry.npmjs.org/wordnet-db/-/wordnet-db-3.1.11.tgz",
"integrity": "sha1-75kaOOmGq5HhsDai+ZF5jBNiD5g=", "integrity": "sha512-gU1pmI6SaXA38fA62OoJz1LAYo2B9vnT0lIw6ZCiCel2dlIP8gJ/4EutnkVzenR5QH6X57n/TmWyXPNfiD0uMA=="
"requires": {
"tar": "^3.1"
}
}, },
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
"dev": true "dev": true
},
"yallist": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz",
"integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k="
} }
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "wordpos", "name": "wordpos",
"version": "2.0.0-beta", "version": "2.0.0-beta.1",
"description": "wordpos is a set of part-of-speech utilities for Node.js & browser using the WordNet database.", "description": "wordpos is a set of part-of-speech utilities for Node.js & browser using the WordNet database.",
"author": "Moos <mooster@42at.com>", "author": "Moos <mooster@42at.com>",
"keywords": [ "keywords": [
@ -24,6 +24,7 @@
"lib", "lib",
"src", "src",
"test", "test",
"!test/dict",
"tools" "tools"
], ],
"bin": "./bin/wordpos-cli.js", "bin": "./bin/wordpos-cli.js",
@ -31,7 +32,7 @@
"commander": "^2.0.0", "commander": "^2.0.0",
"symlink-dir": "1.1.3", "symlink-dir": "1.1.3",
"underscore": ">=1.3.1", "underscore": ">=1.3.1",
"wordnet-db": "^3.1.6" "wordnet-db": "^3.1.11"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.0.0", "@babel/core": "^7.0.0",
@ -74,7 +75,7 @@
"test-browser": "mocha test/wordpos_test --require @babel/register", "test-browser": "mocha test/wordpos_test --require @babel/register",
"prestart": "symlink-dir dict samples/self-hosted/dict", "prestart": "symlink-dir dict samples/self-hosted/dict",
"start": "npm run build && http-server", "start": "npm run build && http-server",
"prestart-dev": "rm -rf build && mkdir build && symlink-dir dict build/dict && cp samples/self-hosted/main.js build/main.txt", "prestart-dev": "rm -rf build && mkdir build && symlink-dir dict build/dict && cp samples/main.js build/main.txt",
"start-dev": "npm run start-self -- -d build", "start-dev": "npm run start-self -- -d build",
"start-self": "parcel samples/self-hosted/index.html", "start-self": "parcel samples/self-hosted/index.html",
"start-cdn": "parcel samples/cdn/index.html" "start-cdn": "parcel samples/cdn/index.html"

View File

@ -88,6 +88,19 @@ function prepText(text) {
)); ));
} }
// node <= 6 polyfill
// @see https://github.com/tc39/proposal-object-values-entries/blob/master/polyfill.js
const reduce = Function.bind.call(Function.call, Array.prototype.reduce);
const isEnumerable = Function.bind.call(Function.call, Object.prototype.propertyIsEnumerable);
const concat = Function.bind.call(Function.call, Array.prototype.concat);
const keys = Reflect.ownKeys;
if (!Object.values) {
Object.values = function values(O) {
return reduce(keys(O), (v, k) => concat(v, typeof k === 'string' && isEnumerable(O, k) ? [O[k]] : []), []);
};
}
module.exports = { module.exports = {
isString, isString,
zeroPad, zeroPad,