monero-nodejs-libwallet
Advanced tools
Comparing version 0.3.7 to 0.3.9
3.1.0 / 2017-09-26 | ||
================== | ||
* Add `DEBUG_HIDE_DATE` env var (#486) | ||
* Remove ReDoS regexp in %o formatter (#504) | ||
* Remove "component" from package.json | ||
* Remove `component.json` | ||
* Ignore package-lock.json | ||
* Examples: fix colors printout | ||
* Fix: browser detection | ||
* Fix: spelling mistake (#496, @EdwardBetts) | ||
3.0.1 / 2017-08-24 | ||
================== | ||
* Fix: Disable colors in Edge and Internet Explorer (#489) | ||
3.0.0 / 2017-08-08 | ||
================== | ||
* Breaking: Remove DEBUG_FD (#406) | ||
* Breaking: Use `Date#toISOString()` instead to `Date#toUTCString()` when output is not a TTY (#418) | ||
* Breaking: Make millisecond timer namespace specific and allow 'always enabled' output (#408) | ||
* Addition: document `enabled` flag (#465) | ||
* Addition: add 256 colors mode (#481) | ||
* Addition: `enabled()` updates existing debug instances, add `destroy()` function (#440) | ||
* Update: component: update "ms" to v2.0.0 | ||
* Update: separate the Node and Browser tests in Travis-CI | ||
* Update: refactor Readme, fixed documentation, added "Namespace Colors" section, redid screenshots | ||
* Update: separate Node.js and web browser examples for organization | ||
* Update: update "browserify" to v14.4.0 | ||
* Fix: fix Readme typo (#473) | ||
2.6.9 / 2017-09-22 | ||
@@ -30,3 +63,3 @@ ================== | ||
* Fix: bug that would occure if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) | ||
* Fix: bug that would occur if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) | ||
* Chore: ignore bower.json in npm installations. (#437, @joaovieira) | ||
@@ -33,0 +66,0 @@ * Misc: update "ms" to v0.7.3 (@tootallnate) |
{ | ||
"_args": [ | ||
[ | ||
"debug@2.6.9", | ||
"debug@3.2.6", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "debug@2.6.9", | ||
"_id": "debug@2.6.9", | ||
"_from": "debug@3.2.6", | ||
"_id": "debug@3.2.6", | ||
"_inBundle": false, | ||
"_integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", | ||
"_integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", | ||
"_location": "/debug", | ||
@@ -17,15 +17,14 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "debug@2.6.9", | ||
"raw": "debug@3.2.6", | ||
"name": "debug", | ||
"escapedName": "debug", | ||
"rawSpec": "2.6.9", | ||
"rawSpec": "3.2.6", | ||
"saveSpec": null, | ||
"fetchSpec": "2.6.9" | ||
"fetchSpec": "3.2.6" | ||
}, | ||
"_requiredBy": [ | ||
"/needle", | ||
"/tap-mocha-reporter" | ||
"/needle" | ||
], | ||
"_resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", | ||
"_spec": "2.6.9", | ||
"_resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", | ||
"_spec": "3.2.6", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -40,8 +39,2 @@ "author": { | ||
}, | ||
"component": { | ||
"scripts": { | ||
"debug/index.js": "browser.js", | ||
"debug/debug.js": "debug.js" | ||
} | ||
}, | ||
"contributors": [ | ||
@@ -59,23 +52,30 @@ { | ||
"dependencies": { | ||
"ms": "2.0.0" | ||
"ms": "^2.1.1" | ||
}, | ||
"description": "small debugging utility", | ||
"devDependencies": { | ||
"browserify": "9.0.3", | ||
"@babel/cli": "^7.0.0", | ||
"@babel/core": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"browserify": "14.4.0", | ||
"chai": "^3.5.0", | ||
"concurrently": "^3.1.0", | ||
"coveralls": "^2.11.15", | ||
"eslint": "^3.12.1", | ||
"coveralls": "^3.0.2", | ||
"istanbul": "^0.4.5", | ||
"karma": "^1.3.0", | ||
"karma": "^3.0.0", | ||
"karma-chai": "^0.1.0", | ||
"karma-mocha": "^1.3.0", | ||
"karma-phantomjs-launcher": "^1.0.2", | ||
"karma-sinon": "^1.0.5", | ||
"mocha": "^3.2.0", | ||
"mocha": "^5.2.0", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
"rimraf": "^2.5.4", | ||
"sinon": "^1.17.6", | ||
"sinon-chai": "^2.8.0" | ||
"xo": "^0.23.0" | ||
}, | ||
"files": [ | ||
"src", | ||
"node.js", | ||
"dist/debug.js", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"homepage": "https://github.com/visionmedia/debug#readme", | ||
@@ -94,3 +94,4 @@ "keywords": [ | ||
}, | ||
"version": "2.6.9" | ||
"unpkg": "./dist/debug.js", | ||
"version": "3.2.6" | ||
} |
# debug | ||
[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) | ||
[![Build Status](https://travis-ci.org/visionmedia/debug.svg?branch=master)](https://travis-ci.org/visionmedia/debug) [![Coverage Status](https://coveralls.io/repos/github/visionmedia/debug/badge.svg?branch=master)](https://coveralls.io/github/visionmedia/debug?branch=master) [![Slack](https://visionmedia-community-slackin.now.sh/badge.svg)](https://visionmedia-community-slackin.now.sh/) [![OpenCollective](https://opencollective.com/debug/backers/badge.svg)](#backers) | ||
[![OpenCollective](https://opencollective.com/debug/sponsors/badge.svg)](#sponsors) | ||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png"> | ||
A tiny JavaScript debugging utility modelled after Node.js core's debugging | ||
technique. Works in Node.js and web browsers. | ||
A tiny node.js debugging utility modelled after node core's debugging technique. | ||
**Discussion around the V3 API is under way [here](https://github.com/visionmedia/debug/issues/370)** | ||
## Installation | ||
@@ -21,3 +20,3 @@ | ||
Example _app.js_: | ||
Example [_app.js_](./examples/node/app.js): | ||
@@ -31,3 +30,3 @@ ```js | ||
debug('booting %s', name); | ||
debug('booting %o', name); | ||
@@ -46,58 +45,124 @@ http.createServer(function(req, res){ | ||
Example _worker.js_: | ||
Example [_worker.js_](./examples/node/worker.js): | ||
```js | ||
var debug = require('debug')('worker'); | ||
var a = require('debug')('worker:a') | ||
, b = require('debug')('worker:b'); | ||
setInterval(function(){ | ||
debug('doing some work'); | ||
}, 1000); | ||
function work() { | ||
a('doing lots of uninteresting work'); | ||
setTimeout(work, Math.random() * 1000); | ||
} | ||
work(); | ||
function workb() { | ||
b('doing some work'); | ||
setTimeout(workb, Math.random() * 2000); | ||
} | ||
workb(); | ||
``` | ||
The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: | ||
The `DEBUG` environment variable is then used to enable these based on space or | ||
comma-delimited names. | ||
![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) | ||
Here are some examples: | ||
![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) | ||
<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png"> | ||
<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png"> | ||
<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png"> | ||
#### Windows note | ||
#### Windows command prompt notes | ||
On Windows the environment variable is set using the `set` command. | ||
##### CMD | ||
```cmd | ||
set DEBUG=*,-not_this | ||
``` | ||
On Windows the environment variable is set using the `set` command. | ||
Note that PowerShell uses different syntax to set environment variables. | ||
```cmd | ||
set DEBUG=*,-not_this | ||
``` | ||
```cmd | ||
$env:DEBUG = "*,-not_this" | ||
``` | ||
Example: | ||
```cmd | ||
set DEBUG=* & node app.js | ||
``` | ||
##### PowerShell (VS Code default) | ||
PowerShell uses different syntax to set environment variables. | ||
```cmd | ||
$env:DEBUG = "*,-not_this" | ||
``` | ||
Example: | ||
```cmd | ||
$env:DEBUG='app';node app.js | ||
``` | ||
Then, run the program to be debugged as usual. | ||
npm script example: | ||
```js | ||
"windowsDebug": "@powershell -Command $env:DEBUG='*';node app.js", | ||
``` | ||
## Namespace Colors | ||
Every debug instance has a color generated for it based on its namespace name. | ||
This helps when visually parsing the debug output to identify which debug instance | ||
a debug line belongs to. | ||
#### Node.js | ||
In Node.js, colors are enabled when stderr is a TTY. You also _should_ install | ||
the [`supports-color`](https://npmjs.org/supports-color) module alongside debug, | ||
otherwise debug will only use a small handful of basic colors. | ||
<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png"> | ||
#### Web Browser | ||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting | ||
option. These are WebKit web inspectors, Firefox ([since version | ||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) | ||
and the Firebug plugin for Firefox (any version). | ||
<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png"> | ||
## Millisecond diff | ||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. | ||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. | ||
![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) | ||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png"> | ||
When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: | ||
When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below: | ||
![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) | ||
<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png"> | ||
## Conventions | ||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". | ||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output. | ||
## Wildcards | ||
The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. | ||
The `*` character may be used as a wildcard. Suppose for example your library has | ||
debuggers named "connect:bodyParser", "connect:compress", "connect:session", | ||
instead of listing all three with | ||
`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do | ||
`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. | ||
You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". | ||
You can also exclude specific debuggers by prefixing them with a "-" character. | ||
For example, `DEBUG=*,-connect:*` would include all debuggers except those | ||
starting with "connect:". | ||
## Environment Variables | ||
When running through Node.js, you can set a few environment variables that will | ||
change the behavior of the debug logging: | ||
When running through Node.js, you can set a few environment variables that will | ||
change the behavior of the debug logging: | ||
@@ -107,18 +172,19 @@ | Name | Purpose | | ||
| `DEBUG` | Enables/disables specific debugging namespaces. | | ||
| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). | | ||
| `DEBUG_COLORS`| Whether or not to use colors in the debug output. | | ||
| `DEBUG_DEPTH` | Object inspection depth. | | ||
| `DEBUG_DEPTH` | Object inspection depth. | | ||
| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | | ||
__Note:__ The environment variables beginning with `DEBUG_` end up being | ||
converted into an Options object that gets used with `%o`/`%O` formatters. | ||
See the Node.js documentation for | ||
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) | ||
for the complete list. | ||
__Note:__ The environment variables beginning with `DEBUG_` end up being | ||
converted into an Options object that gets used with `%o`/`%O` formatters. | ||
See the Node.js documentation for | ||
[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) | ||
for the complete list. | ||
## Formatters | ||
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. | ||
Below are the officially supported formatters: | ||
Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. Below are the officially supported formatters: | ||
| Formatter | Representation | | ||
@@ -133,5 +199,8 @@ |-----------|----------------| | ||
### Custom formatters | ||
You can add custom formatters by extending the `debug.formatters` object. For example, if you wanted to add support for rendering a Buffer as hex with `%h`, you could do something like: | ||
You can add custom formatters by extending the `debug.formatters` object. | ||
For example, if you wanted to add support for rendering a Buffer as hex with | ||
`%h`, you could do something like: | ||
@@ -150,11 +219,13 @@ ```js | ||
## Browser support | ||
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), | ||
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), | ||
if you don't want to build it yourself. | ||
Debug's enable state is currently persisted by `localStorage`. | ||
Consider the situation shown below where you have `worker:a` and `worker:b`, | ||
and wish to debug both. You can enable this using `localStorage.debug`: | ||
## Browser Support | ||
You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), | ||
or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), | ||
if you don't want to build it yourself. | ||
Debug's enable state is currently persisted by `localStorage`. | ||
Consider the situation shown below where you have `worker:a` and `worker:b`, | ||
and wish to debug both. You can enable this using `localStorage.debug`: | ||
```js | ||
@@ -179,14 +250,3 @@ localStorage.debug = 'worker:*' | ||
#### Web Inspector Colors | ||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting | ||
option. These are WebKit web inspectors, Firefox ([since version | ||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) | ||
and the Firebug plugin for Firefox (any version). | ||
Colored output looks something like: | ||
![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) | ||
## Output streams | ||
@@ -196,3 +256,3 @@ | ||
Example _stdout.js_: | ||
Example [_stdout.js_](./examples/node/stdout.js): | ||
@@ -219,3 +279,68 @@ ```js | ||
## Extend | ||
You can simply extend debugger | ||
```js | ||
const log = require('debug')('auth'); | ||
//creates new debug instance with extended namespace | ||
const logSign = log.extend('sign'); | ||
const logLogin = log.extend('login'); | ||
log('hello'); // auth hello | ||
logSign('hello'); //auth:sign hello | ||
logLogin('hello'); //auth:login hello | ||
``` | ||
## Set dynamically | ||
You can also enable debug dynamically by calling the `enable()` method : | ||
```js | ||
let debug = require('debug'); | ||
console.log(1, debug.enabled('test')); | ||
debug.enable('test'); | ||
console.log(2, debug.enabled('test')); | ||
debug.disable(); | ||
console.log(3, debug.enabled('test')); | ||
``` | ||
print : | ||
``` | ||
1 false | ||
2 true | ||
3 false | ||
``` | ||
Usage : | ||
`enable(namespaces)` | ||
`namespaces` can include modes separated by a colon and wildcards. | ||
Note that calling `enable()` completely overrides previously set DEBUG variable : | ||
``` | ||
$ DEBUG=foo node -e 'var dbg = require("debug"); dbg.enable("bar"); console.log(dbg.enabled("foo"))' | ||
=> false | ||
``` | ||
## Checking whether a debug target is enabled | ||
After you've created a debug instance, you can determine whether or not it is | ||
enabled by checking the `enabled` property: | ||
```javascript | ||
const debug = require('debug')('http'); | ||
if (debug.enabled) { | ||
// do stuff... | ||
} | ||
``` | ||
You can also manually toggle this property to force the debug instance to be | ||
enabled or disabled. | ||
## Authors | ||
@@ -226,3 +351,3 @@ | ||
- Andrew Rhyne | ||
## Backers | ||
@@ -303,3 +428,3 @@ | ||
Copyright (c) 2014-2016 TJ Holowaychuk <tj@vision-media.ca> | ||
Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca> | ||
@@ -306,0 +431,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
@@ -0,8 +1,10 @@ | ||
"use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
/* eslint-env browser */ | ||
/** | ||
* This is the web browser implementation of `debug()`. | ||
* | ||
* Expose `debug()` as the module. | ||
*/ | ||
exports = module.exports = require('./debug'); | ||
exports.log = log; | ||
@@ -13,7 +15,3 @@ exports.formatArgs = formatArgs; | ||
exports.useColors = useColors; | ||
exports.storage = 'undefined' != typeof chrome | ||
&& 'undefined' != typeof chrome.storage | ||
? chrome.storage.local | ||
: localstorage(); | ||
exports.storage = localstorage(); | ||
/** | ||
@@ -23,11 +21,3 @@ * Colors. | ||
exports.colors = [ | ||
'lightseagreen', | ||
'forestgreen', | ||
'goldenrod', | ||
'dodgerblue', | ||
'darkorchid', | ||
'crimson' | ||
]; | ||
exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33']; | ||
/** | ||
@@ -40,2 +30,3 @@ * Currently only WebKit-based Web Inspectors, Firefox >= v31, | ||
*/ | ||
// eslint-disable-next-line complexity | ||
@@ -46,31 +37,19 @@ function useColors() { | ||
// explicitly | ||
if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') { | ||
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { | ||
return true; | ||
} | ||
} // Internet Explorer and Edge do not support colors. | ||
// is webkit? http://stackoverflow.com/a/16459606/376773 | ||
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { | ||
return false; | ||
} // Is webkit? http://stackoverflow.com/a/16459606/376773 | ||
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 | ||
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || | ||
// is firebug? http://stackoverflow.com/a/398120/376773 | ||
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) || | ||
// is firefox >= v31? | ||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages | ||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) || | ||
// double check webkit in userAgent just in case we are in a worker | ||
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)); | ||
} | ||
/** | ||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. | ||
*/ | ||
exports.formatters.j = function(v) { | ||
try { | ||
return JSON.stringify(v); | ||
} catch (err) { | ||
return '[UnexpectedJSONParseError]: ' + err.message; | ||
} | ||
}; | ||
return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 | ||
typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? | ||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages | ||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker | ||
typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); | ||
} | ||
/** | ||
@@ -82,27 +61,26 @@ * Colorize log arguments if enabled. | ||
function formatArgs(args) { | ||
var useColors = this.useColors; | ||
args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff); | ||
args[0] = (useColors ? '%c' : '') | ||
+ this.namespace | ||
+ (useColors ? ' %c' : ' ') | ||
+ args[0] | ||
+ (useColors ? '%c ' : ' ') | ||
+ '+' + exports.humanize(this.diff); | ||
if (!this.useColors) { | ||
return; | ||
} | ||
if (!useColors) return; | ||
var c = 'color: ' + this.color; | ||
args.splice(1, 0, c, 'color: inherit') | ||
// the final "%c" is somewhat tricky, because there could be other | ||
args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other | ||
// arguments passed either before or after the %c, so we need to | ||
// figure out the correct index to insert the CSS into | ||
var index = 0; | ||
var lastC = 0; | ||
args[0].replace(/%[a-zA-Z%]/g, function(match) { | ||
if ('%%' === match) return; | ||
args[0].replace(/%[a-zA-Z%]/g, function (match) { | ||
if (match === '%%') { | ||
return; | ||
} | ||
index++; | ||
if ('%c' === match) { | ||
// we only are interested in the *last* %c | ||
if (match === '%c') { | ||
// We only are interested in the *last* %c | ||
// (the user may have provided their own) | ||
@@ -112,6 +90,4 @@ lastC = index; | ||
}); | ||
args.splice(lastC, 0, c); | ||
} | ||
/** | ||
@@ -124,10 +100,10 @@ * Invokes `console.log()` when available. | ||
function log() { | ||
// this hackery is required for IE8/9, where | ||
var _console; | ||
// This hackery is required for IE8/9, where | ||
// the `console.log` function doesn't have 'apply' | ||
return 'object' === typeof console | ||
&& console.log | ||
&& Function.prototype.apply.call(console.log, console, arguments); | ||
return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments); | ||
} | ||
/** | ||
@@ -140,12 +116,14 @@ * Save `namespaces`. | ||
function save(namespaces) { | ||
try { | ||
if (null == namespaces) { | ||
if (namespaces) { | ||
exports.storage.setItem('debug', namespaces); | ||
} else { | ||
exports.storage.removeItem('debug'); | ||
} else { | ||
exports.storage.debug = namespaces; | ||
} | ||
} catch(e) {} | ||
} catch (error) {// Swallow | ||
// XXX (@Qix-) should we be logging these? | ||
} | ||
} | ||
/** | ||
@@ -158,9 +136,13 @@ * Load `namespaces`. | ||
function load() { | ||
var r; | ||
try { | ||
r = exports.storage.debug; | ||
} catch(e) {} | ||
r = exports.storage.getItem('debug'); | ||
} catch (error) {} // Swallow | ||
// XXX (@Qix-) should we be logging these? | ||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG | ||
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG | ||
if (!r && typeof process !== 'undefined' && 'env' in process) { | ||
@@ -172,10 +154,3 @@ r = process.env.DEBUG; | ||
} | ||
/** | ||
* Enable namespaces listed in `localStorage.debug` initially. | ||
*/ | ||
exports.enable(load()); | ||
/** | ||
* Localstorage attempts to return the localstorage. | ||
@@ -191,6 +166,26 @@ * | ||
function localstorage() { | ||
try { | ||
return window.localStorage; | ||
} catch (e) {} | ||
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context | ||
// The Browser also has localStorage in the global context. | ||
return localStorage; | ||
} catch (error) {// Swallow | ||
// XXX (@Qix-) should we be logging these? | ||
} | ||
} | ||
module.exports = require('./common')(exports); | ||
var formatters = module.exports.formatters; | ||
/** | ||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. | ||
*/ | ||
formatters.j = function (v) { | ||
try { | ||
return JSON.stringify(v); | ||
} catch (error) { | ||
return '[UnexpectedJSONParseError]: ' + error.message; | ||
} | ||
}; | ||
@@ -0,7 +1,8 @@ | ||
"use strict"; | ||
/** | ||
* Detect Electron renderer process, which is node, but we should | ||
* Detect Electron renderer / nwjs process, which is node, but we should | ||
* treat as a browser. | ||
*/ | ||
if (typeof process !== 'undefined' && process.type === 'renderer') { | ||
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) { | ||
module.exports = require('./browser.js'); | ||
@@ -11,1 +12,2 @@ } else { | ||
} | ||
@@ -0,15 +1,14 @@ | ||
"use strict"; | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var tty = require('tty'); | ||
var tty = require('tty'); | ||
var util = require('util'); | ||
/** | ||
* This is the Node.js implementation of `debug()`. | ||
* | ||
* Expose `debug()` as the module. | ||
*/ | ||
exports = module.exports = require('./debug'); | ||
exports.init = init; | ||
@@ -21,3 +20,2 @@ exports.log = log; | ||
exports.useColors = useColors; | ||
/** | ||
@@ -29,2 +27,12 @@ * Colors. | ||
try { | ||
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json) | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
var supportsColor = require('supports-color'); | ||
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) { | ||
exports.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221]; | ||
} | ||
} catch (error) {} // Swallow - we only care if `supports-color` is available; it doesn't have to be. | ||
/** | ||
@@ -36,40 +44,27 @@ * Build up the default `inspectOpts` object from the environment variables. | ||
exports.inspectOpts = Object.keys(process.env).filter(function (key) { | ||
return /^debug_/i.test(key); | ||
}).reduce(function (obj, key) { | ||
// camel-case | ||
var prop = key | ||
.substring(6) | ||
.toLowerCase() | ||
.replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() }); | ||
// Camel-case | ||
var prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, function (_, k) { | ||
return k.toUpperCase(); | ||
}); // Coerce string value into JS value | ||
// coerce string value into JS value | ||
var val = process.env[key]; | ||
if (/^(yes|on|true|enabled)$/i.test(val)) val = true; | ||
else if (/^(no|off|false|disabled)$/i.test(val)) val = false; | ||
else if (val === 'null') val = null; | ||
else val = Number(val); | ||
if (/^(yes|on|true|enabled)$/i.test(val)) { | ||
val = true; | ||
} else if (/^(no|off|false|disabled)$/i.test(val)) { | ||
val = false; | ||
} else if (val === 'null') { | ||
val = null; | ||
} else { | ||
val = Number(val); | ||
} | ||
obj[prop] = val; | ||
return obj; | ||
}, {}); | ||
/** | ||
* The file descriptor to write the `debug()` calls to. | ||
* Set the `DEBUG_FD` env variable to override with another value. i.e.: | ||
* | ||
* $ DEBUG_FD=3 node script.js 3>debug.log | ||
*/ | ||
var fd = parseInt(process.env.DEBUG_FD, 10) || 2; | ||
if (1 !== fd && 2 !== fd) { | ||
util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')() | ||
} | ||
var stream = 1 === fd ? process.stdout : | ||
2 === fd ? process.stderr : | ||
createWritableStdioStream(fd); | ||
/** | ||
* Is stdout a TTY? Colored output is enabled when `true`. | ||
@@ -79,29 +74,5 @@ */ | ||
function useColors() { | ||
return 'colors' in exports.inspectOpts | ||
? Boolean(exports.inspectOpts.colors) | ||
: tty.isatty(fd); | ||
return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd); | ||
} | ||
/** | ||
* Map %o to `util.inspect()`, all on a single line. | ||
*/ | ||
exports.formatters.o = function(v) { | ||
this.inspectOpts.colors = this.useColors; | ||
return util.inspect(v, this.inspectOpts) | ||
.split('\n').map(function(str) { | ||
return str.trim() | ||
}).join(' '); | ||
}; | ||
/** | ||
* Map %o to `util.inspect()`, allowing multiple lines if needed. | ||
*/ | ||
exports.formatters.O = function(v) { | ||
this.inspectOpts.colors = this.useColors; | ||
return util.inspect(v, this.inspectOpts); | ||
}; | ||
/** | ||
* Adds ANSI color escape codes if enabled. | ||
@@ -112,26 +83,33 @@ * | ||
function formatArgs(args) { | ||
var name = this.namespace; | ||
var useColors = this.useColors; | ||
var name = this.namespace, | ||
useColors = this.useColors; | ||
if (useColors) { | ||
var c = this.color; | ||
var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m'; | ||
var colorCode = "\x1B[3" + (c < 8 ? c : '8;5;' + c); | ||
var prefix = " ".concat(colorCode, ";1m").concat(name, " \x1B[0m"); | ||
args[0] = prefix + args[0].split('\n').join('\n' + prefix); | ||
args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); | ||
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + "\x1B[0m"); | ||
} else { | ||
args[0] = new Date().toUTCString() | ||
+ ' ' + name + ' ' + args[0]; | ||
args[0] = getDate() + name + ' ' + args[0]; | ||
} | ||
} | ||
function getDate() { | ||
if (exports.inspectOpts.hideDate) { | ||
return ''; | ||
} | ||
return new Date().toISOString() + ' '; | ||
} | ||
/** | ||
* Invokes `util.format()` with the specified arguments and writes to `stream`. | ||
* Invokes `util.format()` with the specified arguments and writes to stderr. | ||
*/ | ||
function log() { | ||
return stream.write(util.format.apply(util, arguments) + '\n'); | ||
return process.stderr.write(util.format.apply(util, arguments) + '\n'); | ||
} | ||
/** | ||
@@ -144,12 +122,12 @@ * Save `namespaces`. | ||
function save(namespaces) { | ||
if (null == namespaces) { | ||
if (namespaces) { | ||
process.env.DEBUG = namespaces; | ||
} else { | ||
// If you set a process.env field to null or undefined, it gets cast to the | ||
// string 'null' or 'undefined'. Just delete instead. | ||
delete process.env.DEBUG; | ||
} else { | ||
process.env.DEBUG = namespaces; | ||
} | ||
} | ||
/** | ||
@@ -162,75 +140,7 @@ * Load `namespaces`. | ||
function load() { | ||
return process.env.DEBUG; | ||
} | ||
/** | ||
* Copied from `node/src/node.js`. | ||
* | ||
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also | ||
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. | ||
*/ | ||
function createWritableStdioStream (fd) { | ||
var stream; | ||
var tty_wrap = process.binding('tty_wrap'); | ||
// Note stream._type is used for test-module-load-list.js | ||
switch (tty_wrap.guessHandleType(fd)) { | ||
case 'TTY': | ||
stream = new tty.WriteStream(fd); | ||
stream._type = 'tty'; | ||
// Hack to have stream not keep the event loop alive. | ||
// See https://github.com/joyent/node/issues/1726 | ||
if (stream._handle && stream._handle.unref) { | ||
stream._handle.unref(); | ||
} | ||
break; | ||
case 'FILE': | ||
var fs = require('fs'); | ||
stream = new fs.SyncWriteStream(fd, { autoClose: false }); | ||
stream._type = 'fs'; | ||
break; | ||
case 'PIPE': | ||
case 'TCP': | ||
var net = require('net'); | ||
stream = new net.Socket({ | ||
fd: fd, | ||
readable: false, | ||
writable: true | ||
}); | ||
// FIXME Should probably have an option in net.Socket to create a | ||
// stream from an existing fd which is writable only. But for now | ||
// we'll just add this hack and set the `readable` member to false. | ||
// Test: ./node test/fixtures/echo.js < /etc/passwd | ||
stream.readable = false; | ||
stream.read = null; | ||
stream._type = 'pipe'; | ||
// FIXME Hack to have stream not keep the event loop alive. | ||
// See https://github.com/joyent/node/issues/1726 | ||
if (stream._handle && stream._handle.unref) { | ||
stream._handle.unref(); | ||
} | ||
break; | ||
default: | ||
// Probably an error on in uv_guess_handle() | ||
throw new Error('Implement me. Unknown stream file type!'); | ||
} | ||
// For supporting legacy API we put the FD here. | ||
stream.fd = fd; | ||
stream._isStdio = true; | ||
return stream; | ||
} | ||
/** | ||
* Init logic for `debug` instances. | ||
@@ -242,6 +152,7 @@ * | ||
function init (debug) { | ||
function init(debug) { | ||
debug.inspectOpts = {}; | ||
var keys = Object.keys(exports.inspectOpts); | ||
var keys = Object.keys(exports.inspectOpts); | ||
for (var i = 0; i < keys.length; i++) { | ||
@@ -252,6 +163,21 @@ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]]; | ||
module.exports = require('./common')(exports); | ||
var formatters = module.exports.formatters; | ||
/** | ||
* Enable namespaces listed in `process.env.DEBUG` initially. | ||
* Map %o to `util.inspect()`, all on a single line. | ||
*/ | ||
exports.enable(load()); | ||
formatters.o = function (v) { | ||
this.inspectOpts.colors = this.useColors; | ||
return util.inspect(v, this.inspectOpts).replace(/\s*\n\s*/g, ' '); | ||
}; | ||
/** | ||
* Map %O to `util.inspect()`, allowing multiple lines if needed. | ||
*/ | ||
formatters.O = function (v) { | ||
this.inspectOpts.colors = this.useColors; | ||
return util.inspect(v, this.inspectOpts); | ||
}; | ||
@@ -9,3 +9,3 @@ 'use strict' | ||
const writeBuffers = binding.writeBuffers | ||
const FSReqWrap = binding.FSReqWrap | ||
const FSReqWrap = binding.FSReqWrap || binding.FSReqCallback | ||
@@ -12,0 +12,0 @@ const _autoClose = Symbol('_autoClose') |
{ | ||
"_args": [ | ||
[ | ||
"fs-minipass@1.2.5", | ||
"fs-minipass@1.2.6", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "fs-minipass@1.2.5", | ||
"_id": "fs-minipass@1.2.5", | ||
"_from": "fs-minipass@1.2.6", | ||
"_id": "fs-minipass@1.2.6", | ||
"_inBundle": false, | ||
"_integrity": "sha512-JhBl0skXjUPCFH7x6x61gQxrKyXsxB5gcgePLZCwfyCGGsTISMoIeObbrvVeP6Xmyaudw4TT43qV2Gz+iyd2oQ==", | ||
"_integrity": "sha512-crhvyXcMejjv3Z5d2Fa9sf5xLYVCF5O1c71QxbVnbLsmYMBEvDAftewesN/HhY03YRoA7zOMxjNGrF5svGaaeQ==", | ||
"_location": "/fs-minipass", | ||
@@ -17,8 +17,8 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "fs-minipass@1.2.5", | ||
"raw": "fs-minipass@1.2.6", | ||
"name": "fs-minipass", | ||
"escapedName": "fs-minipass", | ||
"rawSpec": "1.2.5", | ||
"rawSpec": "1.2.6", | ||
"saveSpec": null, | ||
"fetchSpec": "1.2.5" | ||
"fetchSpec": "1.2.6" | ||
}, | ||
@@ -28,4 +28,4 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.5.tgz", | ||
"_spec": "1.2.5", | ||
"_resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.6.tgz", | ||
"_spec": "1.2.6", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -46,3 +46,3 @@ "author": { | ||
"mutate-fs": "^2.0.1", | ||
"tap": "^10.7.2" | ||
"tap": "^13.1.9" | ||
}, | ||
@@ -62,8 +62,11 @@ "files": [ | ||
"scripts": { | ||
"postpublish": "git push origin --all; git push origin --tags", | ||
"postpublish": "git push origin --follow-tags", | ||
"postversion": "npm publish", | ||
"preversion": "npm test", | ||
"test": "tap test/*.js --100 -J" | ||
"test": "tap" | ||
}, | ||
"version": "1.2.5" | ||
"tap": { | ||
"check-coverage": true | ||
}, | ||
"version": "1.2.6" | ||
} |
@@ -360,3 +360,2 @@ 'use strict' | ||
this.once('data', ondata) | ||
this.resume() | ||
}) | ||
@@ -363,0 +362,0 @@ } |
{ | ||
"_args": [ | ||
[ | ||
"minipass@2.3.4", | ||
"minipass@2.3.5", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "minipass@2.3.4", | ||
"_id": "minipass@2.3.4", | ||
"_from": "minipass@2.3.5", | ||
"_id": "minipass@2.3.5", | ||
"_inBundle": false, | ||
"_integrity": "sha512-mlouk1OHlaUE8Odt1drMtG1bAJA4ZA6B/ehysgV0LUIrDHdKgo1KorZq3pK0b/7Z7LJIQ12MNM6aC+Tn6lUZ5w==", | ||
"_integrity": "sha512-Gi1W4k059gyRbyVUZQ4mEqLm0YIUiGYfvxhF6SIlk3ui1WVxMTGfGdQ2SInh3PDrRTVvPKgULkpJtT4RH10+VA==", | ||
"_location": "/minipass", | ||
@@ -17,8 +17,8 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "minipass@2.3.4", | ||
"raw": "minipass@2.3.5", | ||
"name": "minipass", | ||
"escapedName": "minipass", | ||
"rawSpec": "2.3.4", | ||
"rawSpec": "2.3.5", | ||
"saveSpec": null, | ||
"fetchSpec": "2.3.4" | ||
"fetchSpec": "2.3.5" | ||
}, | ||
@@ -29,7 +29,8 @@ "_requiredBy": [ | ||
"/tap", | ||
"/tap-mocha-reporter/tap-parser", | ||
"/tap-parser", | ||
"/tar" | ||
], | ||
"_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.4.tgz", | ||
"_spec": "2.3.4", | ||
"_resolved": "https://registry.npmjs.org/minipass/-/minipass-2.3.5.tgz", | ||
"_spec": "2.3.5", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -75,3 +76,3 @@ "author": { | ||
}, | ||
"version": "2.3.4" | ||
"version": "2.3.5" | ||
} |
@@ -5,3 +5,3 @@ 'use strict' | ||
const Buffer = require('buffer').Buffer | ||
const binding = process.binding('zlib') | ||
const realZlib = require('zlib') | ||
@@ -11,2 +11,4 @@ const constants = exports.constants = require('./constants.js') | ||
const OriginalBufferConcat = Buffer.concat | ||
class ZlibError extends Error { | ||
@@ -59,13 +61,9 @@ constructor (msg, errno) { | ||
const _opts = Symbol('opts') | ||
const _chunkSize = Symbol('chunkSize') | ||
const _flushFlag = Symbol('flushFlag') | ||
const _finishFlush = Symbol('finishFlush') | ||
const _handle = Symbol('handle') | ||
const _hadError = Symbol('hadError') | ||
const _buffer = Symbol('buffer') | ||
const _offset = Symbol('offset') | ||
const _onError = Symbol('onError') | ||
const _level = Symbol('level') | ||
const _strategy = Symbol('strategy') | ||
const _ended = Symbol('ended') | ||
const _writeState = Symbol('writeState') | ||
@@ -77,3 +75,2 @@ class Zlib extends MiniPass { | ||
this[_opts] = opts = opts || {} | ||
this[_chunkSize] = opts.chunkSize || constants.Z_DEFAULT_CHUNK | ||
if (opts.flush && !validFlushFlags.has(opts.flush)) { | ||
@@ -126,14 +123,13 @@ throw new TypeError('Invalid flush flag: ' + opts.flush) | ||
this[_handle] = new binding.Zlib(mode) | ||
this[_handle] = new realZlib[mode](opts) | ||
this[_hadError] = false | ||
this[_handle].onerror = (message, errno) => { | ||
this[_onError] = (err) => { | ||
// there is no way to cleanly recover. | ||
// continuing only obscures problems. | ||
this.close() | ||
this[_hadError] = true | ||
const error = new ZlibError(message, errno) | ||
const error = new ZlibError(err.message, err.errno) | ||
this.emit('error', error) | ||
} | ||
this[_handle].on('error', this[_onError]) | ||
@@ -146,26 +142,5 @@ const level = typeof opts.level === 'number' ? opts.level | ||
this[_writeState] = new Uint32Array(2); | ||
const window = opts.windowBits || constants.Z_DEFAULT_WINDOWBITS | ||
const memLevel = opts.memLevel || constants.Z_DEFAULT_MEMLEVEL | ||
// API changed in node v9 | ||
/* istanbul ignore next */ | ||
if (/^v[0-8]\./.test(process.version)) { | ||
this[_handle].init(window, | ||
level, | ||
memLevel, | ||
strategy, | ||
opts.dictionary) | ||
} else { | ||
this[_handle].init(window, | ||
level, | ||
memLevel, | ||
strategy, | ||
this[_writeState], | ||
() => {}, | ||
opts.dictionary) | ||
} | ||
this[_buffer] = Buffer.allocUnsafe(this[_chunkSize]) | ||
this[_offset] = 0 | ||
this[_level] = level | ||
@@ -205,5 +180,14 @@ this[_strategy] = strategy | ||
assert(this[_handle], 'zlib binding closed') | ||
// .params() calls .flush(), but the latter is always async in the | ||
// core zlib. We override .flush() temporarily to intercept that and | ||
// flush synchronously. | ||
const origFlush = this[_handle].flush | ||
this[_handle].flush = (flushFlag, cb) => { | ||
this[_handle].flush = origFlush | ||
this.flush(flushFlag) | ||
cb() | ||
} | ||
this[_handle].params(level, strategy) | ||
/* istanbul ignore else */ | ||
if (!this[_hadError]) { | ||
if (this[_handle]) { | ||
this[_level] = level | ||
@@ -252,63 +236,50 @@ this[_strategy] = strategy | ||
if (typeof chunk === 'string') | ||
chunk = new Buffer(chunk, encoding) | ||
chunk = Buffer.from(chunk, encoding) | ||
let availInBefore = chunk && chunk.length | ||
let availOutBefore = this[_chunkSize] - this[_offset] | ||
let inOff = 0 // the offset of the input buffer | ||
const flushFlag = this[_flushFlag] | ||
let writeReturn = true | ||
assert(this[_handle], 'zlib binding closed') | ||
do { | ||
let res = this[_handle].writeSync( | ||
flushFlag, | ||
chunk, // in | ||
inOff, // in_off | ||
availInBefore, // in_len | ||
this[_buffer], // out | ||
this[_offset], //out_off | ||
availOutBefore // out_len | ||
) | ||
if (this[_hadError]) | ||
break | ||
// API changed in v9 | ||
/* istanbul ignore next */ | ||
let availInAfter = res ? res[0] : this[_writeState][1] | ||
/* istanbul ignore next */ | ||
let availOutAfter = res ? res[1] : this[_writeState][0] | ||
const have = availOutBefore - availOutAfter | ||
assert(have >= 0, 'have should not go down') | ||
if (have > 0) { | ||
const out = this[_buffer].slice( | ||
this[_offset], this[_offset] + have | ||
) | ||
this[_offset] += have | ||
// serve some output to the consumer. | ||
writeReturn = super.write(out) && writeReturn | ||
// _processChunk tries to .close() the native handle after it's done, so we | ||
// intercept that by temporarily making it a no-op. | ||
const nativeHandle = this[_handle]._handle | ||
const originalNativeClose = nativeHandle.close | ||
nativeHandle.close = () => {} | ||
const originalClose = this[_handle].close | ||
this[_handle].close = () => {} | ||
// It also calls `Buffer.concat()` at the end, which may be convenient | ||
// for some, but which we are not interested in as it slows us down. | ||
Buffer.concat = (args) => args | ||
let result | ||
try { | ||
result = this[_handle]._processChunk(chunk, this[_flushFlag]) | ||
} catch (err) { | ||
this[_onError](err) | ||
} finally { | ||
Buffer.concat = OriginalBufferConcat | ||
if (this[_handle]) { | ||
// Core zlib resets `_handle` to null after attempting to close the | ||
// native handle. Our no-op handler prevented actual closure, but we | ||
// need to restore the `._handle` property. | ||
this[_handle]._handle = nativeHandle | ||
nativeHandle.close = originalNativeClose | ||
this[_handle].close = originalClose | ||
// `_processChunk()` adds an 'error' listener. If we don't remove it | ||
// after each call, these handlers start piling up. | ||
this[_handle].removeAllListeners('error') | ||
} | ||
} | ||
// exhausted the output buffer, or used all the input create a new one. | ||
if (availOutAfter === 0 || this[_offset] >= this[_chunkSize]) { | ||
availOutBefore = this[_chunkSize] | ||
this[_offset] = 0 | ||
this[_buffer] = Buffer.allocUnsafe(this[_chunkSize]) | ||
let writeReturn | ||
if (result) { | ||
if (Array.isArray(result) && result.length > 0) { | ||
// The first buffer is always `handle._outBuffer`, which would be | ||
// re-used for later invocations; so, we always have to copy that one. | ||
writeReturn = super.write(Buffer.from(result[0])) | ||
for (let i = 1; i < result.length; i++) { | ||
writeReturn = super.write(result[i]) | ||
} | ||
} else { | ||
writeReturn = super.write(Buffer.from(result)) | ||
} | ||
} | ||
if (availOutAfter === 0) { | ||
// Not actually done. Need to reprocess. | ||
// Also, update the availInBefore to the availInAfter value, | ||
// so that if we have to hit it a third (fourth, etc.) time, | ||
// it'll have the correct byte counts. | ||
inOff += (availInBefore - availInAfter) | ||
availInBefore = availInAfter | ||
continue | ||
} | ||
break | ||
} while (!this[_hadError]) | ||
if (cb) | ||
@@ -323,3 +294,3 @@ cb() | ||
constructor (opts) { | ||
super(opts, constants.DEFLATE) | ||
super(opts, 'Deflate') | ||
} | ||
@@ -330,3 +301,3 @@ } | ||
constructor (opts) { | ||
super(opts, constants.INFLATE) | ||
super(opts, 'Inflate') | ||
} | ||
@@ -338,3 +309,3 @@ } | ||
constructor (opts) { | ||
super(opts, constants.GZIP) | ||
super(opts, 'Gzip') | ||
} | ||
@@ -345,3 +316,3 @@ } | ||
constructor (opts) { | ||
super(opts, constants.GUNZIP) | ||
super(opts, 'Gunzip') | ||
} | ||
@@ -353,3 +324,3 @@ } | ||
constructor (opts) { | ||
super(opts, constants.DEFLATERAW) | ||
super(opts, 'DeflateRaw') | ||
} | ||
@@ -360,3 +331,3 @@ } | ||
constructor (opts) { | ||
super(opts, constants.INFLATERAW) | ||
super(opts, 'InflateRaw') | ||
} | ||
@@ -368,3 +339,3 @@ } | ||
constructor (opts) { | ||
super(opts, constants.UNZIP) | ||
super(opts, 'Unzip') | ||
} | ||
@@ -371,0 +342,0 @@ } |
{ | ||
"_args": [ | ||
[ | ||
"minizlib@1.1.0", | ||
"minizlib@1.2.1", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "minizlib@1.1.0", | ||
"_id": "minizlib@1.1.0", | ||
"_from": "minizlib@1.2.1", | ||
"_id": "minizlib@1.2.1", | ||
"_inBundle": false, | ||
"_integrity": "sha512-4T6Ur/GctZ27nHfpt9THOdRZNgyJ9FZchYO1ceg5S8Q3DNLCKYy44nCZzgCJgcvx2UM8czmqak5BCxJMrq37lA==", | ||
"_integrity": "sha512-7+4oTUOWKg7AuL3vloEWekXY2/D20cevzsrNT2kGWm+39J9hGTCBv8VI5Pm5lXZ/o3/mdR4f8rflAPhnQb8mPA==", | ||
"_location": "/minizlib", | ||
@@ -17,8 +17,8 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "minizlib@1.1.0", | ||
"raw": "minizlib@1.2.1", | ||
"name": "minizlib", | ||
"escapedName": "minizlib", | ||
"rawSpec": "1.1.0", | ||
"rawSpec": "1.2.1", | ||
"saveSpec": null, | ||
"fetchSpec": "1.1.0" | ||
"fetchSpec": "1.2.1" | ||
}, | ||
@@ -28,4 +28,4 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.1.0.tgz", | ||
"_spec": "1.1.0", | ||
"_resolved": "https://registry.npmjs.org/minizlib/-/minizlib-1.2.1.tgz", | ||
"_spec": "1.2.1", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -45,3 +45,3 @@ "author": { | ||
"devDependencies": { | ||
"tap": "^10.7.2" | ||
"tap": "^12.0.1" | ||
}, | ||
@@ -76,3 +76,3 @@ "files": [ | ||
}, | ||
"version": "1.1.0" | ||
"version": "1.2.1" | ||
} |
@@ -9,2 +9,3 @@ /** | ||
var d = h * 24; | ||
var w = d * 7; | ||
var y = d * 365.25; | ||
@@ -53,3 +54,3 @@ | ||
} | ||
var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec( | ||
var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( | ||
str | ||
@@ -69,2 +70,6 @@ ); | ||
return n * y; | ||
case 'weeks': | ||
case 'week': | ||
case 'w': | ||
return n * w; | ||
case 'days': | ||
@@ -112,12 +117,13 @@ case 'day': | ||
function fmtShort(ms) { | ||
if (ms >= d) { | ||
var msAbs = Math.abs(ms); | ||
if (msAbs >= d) { | ||
return Math.round(ms / d) + 'd'; | ||
} | ||
if (ms >= h) { | ||
if (msAbs >= h) { | ||
return Math.round(ms / h) + 'h'; | ||
} | ||
if (ms >= m) { | ||
if (msAbs >= m) { | ||
return Math.round(ms / m) + 'm'; | ||
} | ||
if (ms >= s) { | ||
if (msAbs >= s) { | ||
return Math.round(ms / s) + 's'; | ||
@@ -137,7 +143,16 @@ } | ||
function fmtLong(ms) { | ||
return plural(ms, d, 'day') || | ||
plural(ms, h, 'hour') || | ||
plural(ms, m, 'minute') || | ||
plural(ms, s, 'second') || | ||
ms + ' ms'; | ||
var msAbs = Math.abs(ms); | ||
if (msAbs >= d) { | ||
return plural(ms, msAbs, d, 'day'); | ||
} | ||
if (msAbs >= h) { | ||
return plural(ms, msAbs, h, 'hour'); | ||
} | ||
if (msAbs >= m) { | ||
return plural(ms, msAbs, m, 'minute'); | ||
} | ||
if (msAbs >= s) { | ||
return plural(ms, msAbs, s, 'second'); | ||
} | ||
return ms + ' ms'; | ||
} | ||
@@ -149,10 +164,5 @@ | ||
function plural(ms, n, name) { | ||
if (ms < n) { | ||
return; | ||
} | ||
if (ms < n * 1.5) { | ||
return Math.floor(ms / n) + ' ' + name; | ||
} | ||
return Math.ceil(ms / n) + ' ' + name + 's'; | ||
function plural(ms, msAbs, n, name) { | ||
var isPlural = msAbs >= n * 1.5; | ||
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); | ||
} |
{ | ||
"_args": [ | ||
[ | ||
"ms@2.0.0", | ||
"ms@2.1.1", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "ms@2.0.0", | ||
"_id": "ms@2.0.0", | ||
"_from": "ms@2.1.1", | ||
"_id": "ms@2.1.1", | ||
"_inBundle": false, | ||
"_integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", | ||
"_integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", | ||
"_location": "/ms", | ||
@@ -17,14 +17,17 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "ms@2.0.0", | ||
"raw": "ms@2.1.1", | ||
"name": "ms", | ||
"escapedName": "ms", | ||
"rawSpec": "2.0.0", | ||
"rawSpec": "2.1.1", | ||
"saveSpec": null, | ||
"fetchSpec": "2.0.0" | ||
"fetchSpec": "2.1.1" | ||
}, | ||
"_requiredBy": [ | ||
"/debug" | ||
"/@babel/traverse/debug", | ||
"/debug", | ||
"/istanbul-lib-source-maps/debug", | ||
"/treport" | ||
], | ||
"_resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", | ||
"_spec": "2.0.0", | ||
"_resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", | ||
"_spec": "2.1.1", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -34,9 +37,9 @@ "bugs": { | ||
}, | ||
"description": "Tiny milisecond conversion utility", | ||
"description": "Tiny millisecond conversion utility", | ||
"devDependencies": { | ||
"eslint": "3.19.0", | ||
"eslint": "4.12.1", | ||
"expect.js": "0.3.1", | ||
"husky": "0.13.3", | ||
"lint-staged": "3.4.1", | ||
"mocha": "3.4.1" | ||
"husky": "0.14.3", | ||
"lint-staged": "5.0.0", | ||
"mocha": "4.0.1" | ||
}, | ||
@@ -73,3 +76,3 @@ "eslintConfig": { | ||
}, | ||
"version": "2.0.0" | ||
"version": "2.1.1" | ||
} |
@@ -20,5 +20,8 @@ # ms | ||
ms('100') // 100 | ||
ms('-3 days') // -259200000 | ||
ms('-1h') // -3600000 | ||
ms('-200') // -200 | ||
``` | ||
### Convert from milliseconds | ||
### Convert from Milliseconds | ||
@@ -28,6 +31,7 @@ ```js | ||
ms(2 * 60000) // "2m" | ||
ms(-3 * 60000) // "-3m" | ||
ms(ms('10 hours')) // "10h" | ||
``` | ||
### Time format written-out | ||
### Time Format Written-Out | ||
@@ -37,2 +41,3 @@ ```js | ||
ms(2 * 60000, { long: true }) // "2 minutes" | ||
ms(-3 * 60000, { long: true }) // "-3 minutes" | ||
ms(ms('10 hours'), { long: true }) // "10 hours" | ||
@@ -43,13 +48,17 @@ ``` | ||
- Works both in [node](https://nodejs.org) and in the browser. | ||
- If a number is supplied to `ms`, a string with a unit is returned. | ||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`). | ||
- If you pass a string with a number and a valid unit, the number of equivalent ms is returned. | ||
- Works both in [Node.js](https://nodejs.org) and in the browser | ||
- If a number is supplied to `ms`, a string with a unit is returned | ||
- If a string that contains the number is supplied, it returns it as a number (e.g.: it returns `100` for `'100'`) | ||
- If you pass a string with a number and a valid unit, the number of equivalent milliseconds is returned | ||
## Caught a bug? | ||
## Related Packages | ||
- [ms.macro](https://github.com/knpwrs/ms.macro) - Run `ms` as a macro at build-time. | ||
## Caught a Bug? | ||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device | ||
2. Link the package to the global module directory: `npm link` | ||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, node will now use your clone of ms! | ||
3. Within the module you want to test your local development instance of ms, just link it to the dependencies: `npm link ms`. Instead of the default one from npm, Node.js will now use your clone of ms! | ||
As always, you can run the tests using: `npm test` |
@@ -5,3 +5,3 @@ var needle = require('./../'); | ||
var black_pixel = new Buffer("R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=", 'base64'); | ||
var black_pixel = Buffer.from("R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=", 'base64'); | ||
@@ -8,0 +8,0 @@ var data = { |
@@ -24,3 +24,3 @@ var createHash = require('crypto').createHash; | ||
var str = typeof pass == 'undefined' ? user : [user, pass].join(':'); | ||
return 'Basic ' + new Buffer(str).toString('base64'); | ||
return 'Basic ' + Buffer.from(str).toString('base64'); | ||
} | ||
@@ -27,0 +27,0 @@ |
@@ -76,3 +76,3 @@ var readFile = require('fs').readFile, | ||
return_part += '\r\n\r\n'; | ||
return_part += new Buffer(String(part.value), 'utf8').toString('binary'); | ||
return_part += Buffer.from(String(part.value), 'utf8').toString('binary'); | ||
append(); | ||
@@ -79,0 +79,0 @@ |
@@ -350,3 +350,3 @@ ////////////////////////////////////////// | ||
// ensure we have a buffer so bytecount is correct. | ||
body = new Buffer(body, config.encoding); | ||
body = Buffer.from(body, config.encoding); | ||
} | ||
@@ -645,3 +645,3 @@ | ||
// We're either pushing buffers or objects, never strings. | ||
if (typeof chunk == 'string') chunk = new Buffer(chunk); | ||
if (typeof chunk == 'string') chunk = Buffer.from(chunk); | ||
@@ -777,2 +777,4 @@ // Push all chunks to resp.body. We'll bind them in resp.end(). | ||
defaults[target_key] = obj[key]; | ||
} else { | ||
throw new Error('Invalid property for defaults:' + target_key); | ||
} | ||
@@ -779,0 +781,0 @@ } |
{ | ||
"_args": [ | ||
[ | ||
"needle@2.2.4", | ||
"needle@2.4.0", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "needle@2.2.4", | ||
"_id": "needle@2.2.4", | ||
"_from": "needle@2.4.0", | ||
"_id": "needle@2.4.0", | ||
"_inBundle": false, | ||
"_integrity": "sha512-HyoqEb4wr/rsoaIDfTH2aVL9nWtQqba2/HvMv+++m8u0dz808MaagKILxtfeSN7QU7nvbQ79zk3vYOJp9zsNEA==", | ||
"_integrity": "sha512-4Hnwzr3mi5L97hMYeNl8wRW/Onhy4nUKR/lVemJ8gJedxxUyBLm9kkrDColJvoSfwi0jCNhD+xCdOtiGDQiRZg==", | ||
"_location": "/needle", | ||
@@ -17,8 +17,8 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "needle@2.2.4", | ||
"raw": "needle@2.4.0", | ||
"name": "needle", | ||
"escapedName": "needle", | ||
"rawSpec": "2.2.4", | ||
"rawSpec": "2.4.0", | ||
"saveSpec": null, | ||
"fetchSpec": "2.2.4" | ||
"fetchSpec": "2.4.0" | ||
}, | ||
@@ -28,4 +28,4 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/needle/-/needle-2.2.4.tgz", | ||
"_spec": "2.2.4", | ||
"_resolved": "https://registry.npmjs.org/needle/-/needle-2.4.0.tgz", | ||
"_spec": "2.4.0", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -43,3 +43,3 @@ "author": { | ||
"dependencies": { | ||
"debug": "^2.1.2", | ||
"debug": "^3.2.6", | ||
"iconv-lite": "^0.4.4", | ||
@@ -50,9 +50,9 @@ "sax": "^1.2.4" | ||
"devDependencies": { | ||
"JSONStream": "", | ||
"jschardet": "", | ||
"mocha": "", | ||
"q": "", | ||
"JSONStream": "^1.3.5", | ||
"jschardet": "^1.6.0", | ||
"mocha": "^5.2.0", | ||
"q": "^1.5.1", | ||
"should": "^13.2.3", | ||
"sinon": "^2.3.0", | ||
"xml2js": "" | ||
"xml2js": "^0.4.19" | ||
}, | ||
@@ -63,3 +63,3 @@ "directories": { | ||
"engines": { | ||
"node": ">= 0.10.x" | ||
"node": ">= 4.4.x" | ||
}, | ||
@@ -109,3 +109,3 @@ "homepage": "https://github.com/tomas/needle#readme", | ||
], | ||
"version": "2.2.4" | ||
"version": "2.4.0" | ||
} |
@@ -81,4 +81,3 @@ Needle | ||
// ... | ||
}) | ||
}); | ||
}); | ||
@@ -85,0 +84,0 @@ // with callback |
@@ -22,3 +22,3 @@ var helpers = require('./helpers'), | ||
var token = header.split(/\s+/).pop(); | ||
return token && new Buffer(token, 'base64').toString().split(':'); | ||
return token && Buffer.from(token, 'base64').toString().split(':'); | ||
} | ||
@@ -25,0 +25,0 @@ |
@@ -132,3 +132,3 @@ var needle = require('../'), | ||
var whatever = 'efbfbdefbfbdefbfbdefbfbdefbfbd2defbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbdefbfbd'; | ||
new Buffer(response.cookies.geo_city).toString('hex').should.eql(whatever) | ||
Buffer.from(response.cookies.geo_city).toString('hex').should.eql(whatever) | ||
done(); | ||
@@ -306,2 +306,2 @@ }); | ||
}); | ||
}); | ||
}); |
@@ -5,3 +5,3 @@ var http = require('http'), | ||
var port = 5432; | ||
var port = 54321; | ||
@@ -8,0 +8,0 @@ describe('request headers', function() { |
@@ -183,3 +183,3 @@ var should = require('should'), | ||
var pixel = new Buffer("base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs", "base64"); | ||
var pixel = Buffer.from("base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs", "base64"); | ||
@@ -186,0 +186,0 @@ before(function() { |
@@ -13,3 +13,3 @@ var needle = require('..'), | ||
// multiparts.push(['\r\næµè¯\r\n----------------------NODENEEDLEHTTPCLIENT--']) | ||
// multiparts.push(['\r\n' + new Buffer('测试').toString() + '\r\n----------------------NODENEEDLEHTTPCLIENT--']) | ||
// multiparts.push(['\r\n' + Buffer.from('测试').toString() + '\r\n----------------------NODENEEDLEHTTPCLIENT--']) | ||
@@ -154,3 +154,3 @@ | ||
spy.args[0][0].should.be.an.instanceof(String); | ||
new Buffer(spy.args[0][0]).toString('hex').should.eql('2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d22666f6f220d0a0d0a6261720d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2274657374220d0a0d0ac3a6c2b5c28bc3a8c2afc2950d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e542d2d') | ||
Buffer.from(spy.args[0][0]).toString('hex').should.eql('2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d22666f6f220d0a0d0a6261720d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2274657374220d0a0d0ac3a6c2b5c28bc3a8c2afc2950d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e542d2d') | ||
done(); | ||
@@ -192,3 +192,3 @@ }) | ||
spy.args[0][0].should.be.an.instanceof(String); | ||
new Buffer(spy.args[0][0]).toString('hex').should.eql('2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d22666f6f220d0a0d0a6261720d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2274657374220d0a0d0ac3a6c2b5c28bc3a8c2afc2950d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e542d2d') | ||
Buffer.from(spy.args[0][0]).toString('hex').should.eql('2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d22666f6f220d0a0d0a6261720d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e540d0a436f6e74656e742d446973706f736974696f6e3a20666f726d2d646174613b206e616d653d2274657374220d0a0d0ac3a6c2b5c28bc3a8c2afc2950d0a2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d4e4f44454e4545444c4548545450434c49454e542d2d') | ||
done(); | ||
@@ -767,3 +767,3 @@ }) | ||
get(new Buffer('foobar'), { json: false }, function(err, resp) { | ||
get(Buffer.from('foobar'), { json: false }, function(err, resp) { | ||
check_request('get'); | ||
@@ -775,3 +775,3 @@ done(); | ||
it('sets Content-Type header', function(done) { | ||
get(new Buffer('foobar'), { json: false }, function(err, resp) { | ||
get(Buffer.from('foobar'), { json: false }, function(err, resp) { | ||
// should.not.exist(resp.body.headers['content-type']); | ||
@@ -785,3 +785,3 @@ resp.body.headers['content-type'].should.equal('application/x-www-form-urlencoded'); | ||
it('doesnt change default Accept header', function(done) { | ||
get(new Buffer('foobar'), { json: false }, function(err, resp) { | ||
get(Buffer.from('foobar'), { json: false }, function(err, resp) { | ||
// resp.body contains 'header' and 'body', mirroring what we sent | ||
@@ -794,3 +794,3 @@ resp.body.headers['accept'].should.equal('*/*'); | ||
it('writes as buffer', function(done) { | ||
get(new Buffer('foobar'), { json: false }, function(err, resp) { | ||
get(Buffer.from('foobar'), { json: false }, function(err, resp) { | ||
spy.called.should.be.true; | ||
@@ -811,3 +811,3 @@ spy.args[0][0].should.be.an.instanceof(Buffer); | ||
get(new Buffer('foobar'), { json: true }, function(err, resp) { | ||
get(Buffer.from('foobar'), { json: true }, function(err, resp) { | ||
check_request('get'); | ||
@@ -819,3 +819,3 @@ done(); | ||
it('sets Content-Type header', function(done) { | ||
get(new Buffer('foobar'), { json: true }, function(err, resp) { | ||
get(Buffer.from('foobar'), { json: true }, function(err, resp) { | ||
resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); | ||
@@ -827,3 +827,3 @@ done(); | ||
it('set Accept header to application/json', function(done) { | ||
get(new Buffer('foobar'), { json: true }, function(err, resp) { | ||
get(Buffer.from('foobar'), { json: true }, function(err, resp) { | ||
resp.body.headers['accept'].should.equal('application/json'); | ||
@@ -835,3 +835,3 @@ done(); | ||
it('writes JSON.stringify version of object', function(done) { | ||
get(new Buffer('foobar'), { json: true }, function(err, resp) { | ||
get(Buffer.from('foobar'), { json: true }, function(err, resp) { | ||
spy.called.should.be.true; | ||
@@ -855,3 +855,3 @@ spy.args[0][0].toString().should.eql('foobar') | ||
post(new Buffer('foobar'), { json: false }, function(err, resp) { | ||
post(Buffer.from('foobar'), { json: false }, function(err, resp) { | ||
check_request('post'); | ||
@@ -863,3 +863,3 @@ done(); | ||
it('sets Content-Type header to www-form-urlencoded', function(done) { | ||
post(new Buffer('foobar'), { json: false }, function(err, resp) { | ||
post(Buffer.from('foobar'), { json: false }, function(err, resp) { | ||
resp.body.headers['content-type'].should.equal('application/x-www-form-urlencoded'); | ||
@@ -871,3 +871,3 @@ done(); | ||
it('doesnt change default Accept header', function(done) { | ||
post(new Buffer('foobar'), { json: false }, function(err, resp) { | ||
post(Buffer.from('foobar'), { json: false }, function(err, resp) { | ||
// resp.body contains 'header' and 'body', mirroring what we sent | ||
@@ -880,3 +880,3 @@ resp.body.headers['accept'].should.equal('*/*'); | ||
it('writes as buffer', function(done) { | ||
post(new Buffer('foobar'), { json: false }, function(err, resp) { | ||
post(Buffer.from('foobar'), { json: false }, function(err, resp) { | ||
spy.called.should.be.true; | ||
@@ -897,3 +897,3 @@ spy.args[0][0].should.be.an.instanceof(Buffer); | ||
post(new Buffer('foobar'), { json: true }, function(err, resp) { | ||
post(Buffer.from('foobar'), { json: true }, function(err, resp) { | ||
check_request('post'); | ||
@@ -905,3 +905,3 @@ done(); | ||
it('sets Content-Type header', function(done) { | ||
post(new Buffer('foobar'), { json: true }, function(err, resp) { | ||
post(Buffer.from('foobar'), { json: true }, function(err, resp) { | ||
resp.body.headers['content-type'].should.equal('application/json; charset=utf-8'); | ||
@@ -913,3 +913,3 @@ done(); | ||
it('set Accept header to application/json', function(done) { | ||
post(new Buffer('foobar'), { json: true }, function(err, resp) { | ||
post(Buffer.from('foobar'), { json: true }, function(err, resp) { | ||
resp.body.headers['accept'].should.equal('application/json'); | ||
@@ -921,3 +921,3 @@ done(); | ||
it('passes raw buffer (assuming its a JSON string beneath)', function(done) { | ||
post(new Buffer('foobar'), { json: true }, function(err, resp) { | ||
post(Buffer.from('foobar'), { json: true }, function(err, resp) { | ||
spy.called.should.be.true; | ||
@@ -1040,2 +1040,2 @@ spy.args[0][0].toString().should.eql('foobar') | ||
}) | ||
}) |
@@ -54,3 +54,3 @@ var helpers = require('./helpers'), | ||
var token = header.split(/\s+/).pop(); | ||
return token && new Buffer(token, 'base64').toString().split(':'); | ||
return token && Buffer.from(token, 'base64').toString().split(':'); | ||
} | ||
@@ -57,0 +57,0 @@ |
@@ -49,3 +49,3 @@ // TODO: write specs. :) | ||
var black_pixel = new Buffer("data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=".replace(/^data:image\/\w+;base64,/, ""), "base64"); | ||
var black_pixel = Buffer.from("data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=".replace(/^data:image\/\w+;base64,/, ""), "base64"); | ||
@@ -52,0 +52,0 @@ var data = { |
# node-pre-gyp changelog | ||
## 0.12.0 | ||
- Fixed double-build problem with node v10 (https://github.com/mapbox/node-pre-gyp/pull/428) | ||
- Added node 11 support in the local database (https://github.com/mapbox/node-pre-gyp/pull/422) | ||
## 0.11.0 | ||
- Fixed double-install problem with node v10 | ||
- Significant N-API improvements (https://github.com/mapbox/node-pre-gyp/pull/405) | ||
## 0.10.3 | ||
- Now will use `request` over `needle` if request is installed. By default `needle` is used for `https`. This should unbreak proxy support that regressed in v0.9.0 | ||
## 0.10.2 | ||
- Fixed rc/deep-extent security vulnerability | ||
- Fixed broken reinstall script do to incorrectly named get_best_napi_version | ||
## 0.10.1 | ||
- Fix needle error event (@medns) | ||
## 0.10.0 | ||
- Allow for a single-level module path when packing @allenluce (https://github.com/mapbox/node-pre-gyp/pull/371) | ||
- Log warnings instead of errors when falling back @xzyfer (https://github.com/mapbox/node-pre-gyp/pull/366) | ||
- Add Node.js v10 support to tests (https://github.com/mapbox/node-pre-gyp/pull/372) | ||
- Remove retire.js from CI (https://github.com/mapbox/node-pre-gyp/pull/372) | ||
- Remove support for Node.js v4 due to [EOL on April 30th, 2018](https://github.com/nodejs/Release/blob/7dd52354049cae99eed0e9fe01345b0722a86fde/schedule.json#L14) | ||
- Update appveyor tests to install default NPM version instead of NPM v2.x for all Windows builds (https://github.com/mapbox/node-pre-gyp/pull/375) | ||
## 0.9.1 | ||
@@ -245,3 +277,3 @@ | ||
- Fixed support for auto-detecting s3 bucket name when it contains `.` - @taavo | ||
- Fixed support for auto-detecting s3 bucket name when it contains `.` - @taavo | ||
- Fixed support for installing when path contains a `'` - @halfdan | ||
@@ -381,3 +413,3 @@ - Ported tests to mocha | ||
- Fixed exception when only stderr is available in binary test (@bendi / #31) | ||
- Fixed exception when only stderr is available in binary test (@bendi / #31) | ||
@@ -403,2 +435,1 @@ ## 0.4.0 | ||
- `.node` modules must be in a folder of there own since tar-pack will remove everything when it unpacks. | ||
@@ -6,6 +6,6 @@ # Contributing | ||
- Ensure tests are passing on travis (okay for appveyor node v4 x86 to fail) | ||
- Ensure tests are passing on travis and appveyor | ||
- Run `node scripts/abi_crosswalk.js` and commit any changes | ||
- Update the changelog | ||
- Tag a new release like: `git tag -a v0.6.34 -m "tagging v0.6.34" && git push --tags` | ||
- Run `npm publish` | ||
- Run `npm publish` |
@@ -24,3 +24,3 @@ "use strict"; | ||
compile.run_gyp(final_args,result.opts,function(err) { | ||
if (!err && result.opts.napi_build_version) { | ||
if (result.opts.napi_build_version) { | ||
napi.swap_build_dir_out(result.opts.napi_build_version); | ||
@@ -27,0 +27,0 @@ } |
@@ -22,2 +22,17 @@ "use strict"; | ||
var http_get = { | ||
impl: undefined, | ||
type: undefined | ||
}; | ||
try { | ||
http_get.impl = require('request'); | ||
http_get.type = 'request'; | ||
log.warn("Using request for node-pre-gyp https download"); | ||
} catch (e) { | ||
http_get.impl = require('needle'); | ||
http_get.type = 'needle'; | ||
log.warn("Using needle for node-pre-gyp https download"); | ||
} | ||
function download(uri,opts,callback) { | ||
@@ -63,3 +78,3 @@ log.http('GET', uri); | ||
try { | ||
req = require('needle').get(requestOpts.uri, requestOpts); | ||
req = http_get.impl.get(requestOpts.uri, requestOpts); | ||
} catch (e) { | ||
@@ -82,2 +97,3 @@ return callback(e); | ||
var extractCount = 0; | ||
var hasResponse = false; | ||
var tar = require('tar'); | ||
@@ -100,9 +116,23 @@ | ||
// for request compatibility | ||
req.on('error', function(err) { | ||
badDownload = true; | ||
return callback(err); | ||
if (!hasResponse) { | ||
hasResponse = true; | ||
return callback(err); | ||
} | ||
}); | ||
// for needle compatibility | ||
req.on('err', function(err) { | ||
badDownload = true; | ||
if (!hasResponse) { | ||
hasResponse = true; | ||
return callback(err); | ||
} | ||
}); | ||
req.on('close', function () { | ||
if (extractCount === 0) { | ||
if (!hasResponse) { | ||
hasResponse = true; | ||
return callback(new Error('Connection closed while downloading tarball file')); | ||
@@ -113,7 +143,11 @@ } | ||
req.on('response', function(res) { | ||
// ignore redirects, needle handles these automatically. | ||
if (res.headers.hasOwnProperty('location') && res.headers.location !== '') { | ||
return; | ||
} | ||
if (res.statusCode !== 200) { | ||
// ignore redirects, needle handles these automatically. | ||
if (http_get.type === 'needle' && res.headers.hasOwnProperty('location') && res.headers.location !== '') { | ||
return; | ||
} | ||
if (hasResponse) { | ||
return; | ||
} | ||
hasResponse = true; | ||
if (res.statusCode !== 200) { | ||
badDownload = true; | ||
@@ -150,4 +184,4 @@ var err = new Error(res.statusCode + ' status code downloading tarball ' + from); | ||
full_message += fallback_message; | ||
log.error("Tried to download(" + err.statusCode + "): " + opts.hosted_tarball); | ||
log.error(full_message); | ||
log.warn("Tried to download(" + err.statusCode + "): " + opts.hosted_tarball); | ||
log.warn(full_message); | ||
log.http(err.message); | ||
@@ -160,4 +194,4 @@ } else { | ||
full_message += fallback_message; | ||
log.error(full_message); | ||
log.error("Hit error " + err.message); | ||
log.warn(full_message); | ||
log.warn("Hit error " + err.message); | ||
} | ||
@@ -164,0 +198,0 @@ } |
@@ -138,3 +138,3 @@ "use strict"; | ||
this.todo = napi.expand_commands (package_json, commands); | ||
this.todo = napi.expand_commands (package_json, this.opts, commands); | ||
@@ -141,0 +141,0 @@ // support for inheriting config env variables from npm |
@@ -36,5 +36,8 @@ "use strict"; | ||
mkdirp(path.dirname(tarball),function(err) { | ||
from = path.dirname(from); | ||
if (err) return callback(err); | ||
packlist({ path: from }).then(function(files) { | ||
var base = path.basename(from); | ||
files = files.map(function(file) { | ||
return path.join(base, file); | ||
}); | ||
tar.create({ | ||
@@ -45,3 +48,3 @@ portable: true, | ||
file: tarball, | ||
cwd: from | ||
cwd: path.dirname(from) | ||
}, files, function(err) { | ||
@@ -48,0 +51,0 @@ if (err) console.error('['+package_json.name+'] ' + err.message); |
@@ -12,4 +12,4 @@ "use strict"; | ||
exports.validate = function(package_json) { | ||
versioning.validate_config(package_json); | ||
exports.validate = function(package_json,opts) { | ||
versioning.validate_config(package_json,opts); | ||
}; | ||
@@ -22,6 +22,6 @@ | ||
var package_json = require(package_json_path); | ||
versioning.validate_config(package_json); | ||
versioning.validate_config(package_json,opts); | ||
var napi_build_version; | ||
if (napi.get_napi_build_versions (package_json)) { | ||
napi_build_version = napi.get_best_napi_build_version(package_json); | ||
if (napi.get_napi_build_versions (package_json, opts)) { | ||
napi_build_version = napi.get_best_napi_build_version(package_json, opts); | ||
} | ||
@@ -28,0 +28,0 @@ opts = opts || {}; |
@@ -16,3 +16,3 @@ "use strict"; | ||
]; | ||
commands = napi.expand_commands(package_json, commands); | ||
commands = napi.expand_commands(package_json, gyp.opts, commands); | ||
for (var i = commands.length; i !== 0; i--) { | ||
@@ -19,0 +19,0 @@ gyp.todo.unshift(commands[i-1]); |
@@ -13,3 +13,3 @@ "use strict"; | ||
var installArgs = []; | ||
var napi_build_version = napi.get_best_napi_version(package_json); | ||
var napi_build_version = napi.get_best_napi_build_version(package_json, gyp.opts); | ||
if (napi_build_version != null) installArgs = [ napi.get_command_arg (napi_build_version) ]; | ||
@@ -16,0 +16,0 @@ gyp.todo.unshift( |
@@ -1266,2 +1266,10 @@ { | ||
}, | ||
"4.9.0": { | ||
"node_abi": 46, | ||
"v8": "4.5" | ||
}, | ||
"4.9.1": { | ||
"node_abi": 46, | ||
"v8": "4.5" | ||
}, | ||
"5.0.0": { | ||
@@ -1483,2 +1491,42 @@ "node_abi": 47, | ||
}, | ||
"6.14.0": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.14.1": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.14.2": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.14.3": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.14.4": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.15.0": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.15.1": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.16.0": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.17.0": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"6.17.1": { | ||
"node_abi": 48, | ||
"v8": "5.1" | ||
}, | ||
"7.0.0": { | ||
@@ -1636,2 +1684,50 @@ "node_abi": 51, | ||
}, | ||
"8.11.0": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.11.1": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.11.2": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.11.3": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.11.4": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.12.0": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.13.0": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.14.0": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.14.1": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.15.0": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.15.1": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"8.16.0": { | ||
"node_abi": 57, | ||
"v8": "6.2" | ||
}, | ||
"9.0.0": { | ||
@@ -1684,3 +1780,187 @@ "node_abi": 59, | ||
"v8": "6.2" | ||
}, | ||
"9.9.0": { | ||
"node_abi": 59, | ||
"v8": "6.2" | ||
}, | ||
"9.10.0": { | ||
"node_abi": 59, | ||
"v8": "6.2" | ||
}, | ||
"9.10.1": { | ||
"node_abi": 59, | ||
"v8": "6.2" | ||
}, | ||
"9.11.0": { | ||
"node_abi": 59, | ||
"v8": "6.2" | ||
}, | ||
"9.11.1": { | ||
"node_abi": 59, | ||
"v8": "6.2" | ||
}, | ||
"9.11.2": { | ||
"node_abi": 59, | ||
"v8": "6.2" | ||
}, | ||
"10.0.0": { | ||
"node_abi": 64, | ||
"v8": "6.6" | ||
}, | ||
"10.1.0": { | ||
"node_abi": 64, | ||
"v8": "6.6" | ||
}, | ||
"10.2.0": { | ||
"node_abi": 64, | ||
"v8": "6.6" | ||
}, | ||
"10.2.1": { | ||
"node_abi": 64, | ||
"v8": "6.6" | ||
}, | ||
"10.3.0": { | ||
"node_abi": 64, | ||
"v8": "6.6" | ||
}, | ||
"10.4.0": { | ||
"node_abi": 64, | ||
"v8": "6.7" | ||
}, | ||
"10.4.1": { | ||
"node_abi": 64, | ||
"v8": "6.7" | ||
}, | ||
"10.5.0": { | ||
"node_abi": 64, | ||
"v8": "6.7" | ||
}, | ||
"10.6.0": { | ||
"node_abi": 64, | ||
"v8": "6.7" | ||
}, | ||
"10.7.0": { | ||
"node_abi": 64, | ||
"v8": "6.7" | ||
}, | ||
"10.8.0": { | ||
"node_abi": 64, | ||
"v8": "6.7" | ||
}, | ||
"10.9.0": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.10.0": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.11.0": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.12.0": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.13.0": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.14.0": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.14.1": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.14.2": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.15.0": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.15.1": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.15.2": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"10.15.3": { | ||
"node_abi": 64, | ||
"v8": "6.8" | ||
}, | ||
"11.0.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.1.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.2.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.3.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.4.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.5.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.6.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.7.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.8.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.9.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.10.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.10.1": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.11.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.12.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.13.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"11.14.0": { | ||
"node_abi": 67, | ||
"v8": "7.0" | ||
}, | ||
"12.0.0": { | ||
"node_abi": 72, | ||
"v8": "7.4" | ||
} | ||
} |
@@ -50,3 +50,4 @@ "use strict"; | ||
'node_abi_napi', | ||
'napi_build_version' | ||
'napi_build_version', | ||
'node_napi_label' | ||
]; | ||
@@ -65,4 +66,6 @@ | ||
node_pre_gyp_options.push('--' + key + '=' + val); | ||
} else if (key === 'napi_build_version') { | ||
node_pre_gyp_options.push('--' + key + '=0'); | ||
} else { | ||
if (key !== 'napi_version' && key !== 'node_abi_napi' && key !== 'napi_build_version') | ||
if (key !== 'napi_version' && key !== 'node_abi_napi') | ||
return callback(new Error("Option " + key + " required but not found by node-pre-gyp")); | ||
@@ -69,0 +72,0 @@ } |
@@ -5,2 +5,3 @@ "use strict"; | ||
var rm = require('rimraf'); | ||
var log = require('npmlog'); | ||
@@ -31,4 +32,5 @@ module.exports = exports; | ||
module.exports.get_napi_version = function() { | ||
module.exports.get_napi_version = function(target) { // target may be undefined | ||
// returns the non-zero numeric napi version or undefined if napi is not supported. | ||
// correctly supporting target requires an updated cross-walk | ||
var version = process.versions.napi; // can be undefined | ||
@@ -42,14 +44,16 @@ if (!version) { // this code should never need to be updated | ||
module.exports.get_napi_version_as_string = function() { | ||
module.exports.get_napi_version_as_string = function(target) { | ||
// returns the napi version as a string or an empty string if napi is not supported. | ||
var version = module.exports.get_napi_version(); | ||
var version = module.exports.get_napi_version(target); | ||
return version ? ''+version : ''; | ||
}; | ||
module.exports.validate_package_json = function(package_json) { // return err | ||
module.exports.validate_package_json = function(package_json, opts) { // throws Error | ||
var binary = package_json.binary; | ||
var module_path_ok = binary.module_path && binary.module_path.indexOf('{napi_build_version}') !== -1; | ||
var remote_path_ok = binary.remote_path && binary.remote_path.indexOf('{napi_build_version}') !== -1; | ||
var package_name_ok = binary.package_name && binary.package_name.indexOf('{napi_build_version}') !== -1; | ||
var napi_build_versions = module.exports.get_napi_build_versions(package_json); | ||
var module_path_ok = pathOK(binary.module_path); | ||
var remote_path_ok = pathOK(binary.remote_path); | ||
var package_name_ok = pathOK(binary.package_name); | ||
var napi_build_versions = module.exports.get_napi_build_versions(package_json,opts,true); | ||
var napi_build_versions_raw = module.exports.get_napi_build_versions_raw(package_json); | ||
@@ -69,3 +73,3 @@ if (napi_build_versions) { | ||
if ((module_path_ok || remote_path_ok || package_name_ok) && !napi_build_versions) { | ||
if ((module_path_ok || remote_path_ok || package_name_ok) && !napi_build_versions_raw) { | ||
throw new Error("When the substitution string '{napi_build_version}` is specified in " + | ||
@@ -75,20 +79,32 @@ "module_path, remote_path, or package_name; napi_versions must also be specified."); | ||
if (napi_build_versions && !module.exports.get_best_napi_build_version(package_json)) { | ||
if (napi_build_versions && !module.exports.get_best_napi_build_version(package_json, opts) && | ||
module.exports.build_napi_only(package_json)) { | ||
throw new Error( | ||
'The N-API version of this Node instance is ' + module.exports.get_napi_version() + '. ' + | ||
'This module supports N-API version(s) ' + module.exports.get_napi_build_versions(package_json) + '. ' + | ||
'The N-API version of this Node instance is ' + module.exports.get_napi_version(opts ? opts.target : undefined) + '. ' + | ||
'This module supports N-API version(s) ' + module.exports.get_napi_build_versions_raw(package_json) + '. ' + | ||
'This Node instance cannot run this module.'); | ||
} | ||
if (napi_build_versions_raw && !napi_build_versions && module.exports.build_napi_only(package_json)) { | ||
throw new Error( | ||
'The N-API version of this Node instance is ' + module.exports.get_napi_version(opts ? opts.target : undefined) + '. ' + | ||
'This module supports N-API version(s) ' + module.exports.get_napi_build_versions_raw(package_json) + '. ' + | ||
'This Node instance cannot run this module.'); | ||
} | ||
}; | ||
module.exports.expand_commands = function(package_json, commands) { | ||
function pathOK (path) { | ||
return path && (path.indexOf('{napi_build_version}') !== -1 || path.indexOf('{node_napi_label}') !== -1); | ||
} | ||
module.exports.expand_commands = function(package_json, opts, commands) { | ||
var expanded_commands = []; | ||
var napi_build_versions = module.exports.get_napi_build_versions(package_json); | ||
var napi_build_versions = module.exports.get_napi_build_versions(package_json, opts); | ||
commands.forEach(function(command){ | ||
if (napi_build_versions && command.name === 'install') { | ||
var napi_build_version = module.exports.get_best_napi_build_version(package_json); | ||
var napi_build_version = module.exports.get_best_napi_build_version(package_json, opts); | ||
var args = napi_build_version ? [ napi_build_version_tag+napi_build_version ] : [ ]; | ||
expanded_commands.push ({ name: command.name, args: args }); | ||
} else if (napi_build_versions && napi_multiple_commands.includes(command.name)) { | ||
} else if (napi_build_versions && napi_multiple_commands.indexOf(command.name) !== -1) { | ||
napi_build_versions.forEach(function(napi_build_version){ | ||
@@ -106,12 +122,39 @@ var args = command.args.slice(); | ||
module.exports.get_napi_build_versions = function(package_json) { | ||
module.exports.get_napi_build_versions = function(package_json, opts, warnings) { // opts may be undefined | ||
var napi_build_versions = []; | ||
if (package_json.binary && package_json.binary.napi_versions) { // remove duplicates | ||
var supported_napi_version = module.exports.get_napi_version(opts ? opts.target : undefined); | ||
// remove duplicates, verify each napi version can actaully be built | ||
if (package_json.binary && package_json.binary.napi_versions) { | ||
package_json.binary.napi_versions.forEach(function(napi_version) { | ||
if (!napi_build_versions.includes(napi_version)) napi_build_versions.push(napi_version); | ||
var duplicated = napi_build_versions.indexOf(napi_version) !== -1; | ||
if (!duplicated && supported_napi_version && napi_version <= supported_napi_version) { | ||
napi_build_versions.push(napi_version); | ||
} else if (warnings && !duplicated && supported_napi_version) { | ||
log.info('This Node instance does not support builds for N-API version', napi_version); | ||
} | ||
}); | ||
} | ||
if (opts && opts["build-latest-napi-version-only"]) { | ||
var latest_version = 0; | ||
napi_build_versions.forEach(function(napi_version) { | ||
if (napi_version > latest_version) latest_version = napi_version; | ||
}); | ||
napi_build_versions = latest_version ? [ latest_version ] : []; | ||
} | ||
return napi_build_versions.length ? napi_build_versions : undefined; | ||
}; | ||
module.exports.get_napi_build_versions_raw = function(package_json) { | ||
var napi_build_versions = []; | ||
// remove duplicates | ||
if (package_json.binary && package_json.binary.napi_versions) { | ||
package_json.binary.napi_versions.forEach(function(napi_version) { | ||
if (napi_build_versions.indexOf(napi_version) === -1) { | ||
napi_build_versions.push(napi_version); | ||
} | ||
}); | ||
} | ||
return napi_build_versions.length ? napi_build_versions : undefined; | ||
}; | ||
module.exports.get_command_arg = function(napi_build_version) { | ||
@@ -149,7 +192,7 @@ return napi_build_version_tag + napi_build_version; | ||
module.exports.get_best_napi_build_version = function(package_json) { | ||
module.exports.get_best_napi_build_version = function(package_json, opts) { | ||
var best_napi_build_version = 0; | ||
var napi_build_versions = module.exports.get_napi_build_versions (package_json); | ||
var napi_build_versions = module.exports.get_napi_build_versions (package_json, opts); | ||
if (napi_build_versions) { | ||
var our_napi_version = module.exports.get_napi_version(); | ||
var our_napi_version = module.exports.get_napi_version(opts ? opts.target : undefined); | ||
napi_build_versions.forEach(function(napi_build_version){ | ||
@@ -164,1 +207,6 @@ if (napi_build_version > best_napi_build_version && | ||
}; | ||
module.exports.build_napi_only = function(package_json) { | ||
return package_json.binary && package_json.binary.package_name && | ||
package_json.binary.package_name.indexOf('{node_napi_label}') === -1; | ||
}; |
@@ -195,3 +195,3 @@ "use strict"; | ||
function validate_config(package_json) { | ||
function validate_config(package_json,opts) { | ||
var msg = package_json.name + ' package.json is not node-pre-gyp ready:\n'; | ||
@@ -230,3 +230,3 @@ var missing = []; | ||
} | ||
napi.validate_package_json(package_json); | ||
napi.validate_package_json(package_json,opts); | ||
} | ||
@@ -281,3 +281,3 @@ | ||
options = options || {}; | ||
validate_config(package_json); | ||
validate_config(package_json,options); // options is a suitable substitute for opts in this case | ||
var v = package_json.version; | ||
@@ -299,5 +299,6 @@ var module_version = semver.parse(v); | ||
node_abi: get_runtime_abi(runtime,options.target), | ||
node_abi_napi: napi.get_napi_version() ? 'napi' : get_runtime_abi(runtime,options.target), | ||
napi_version: napi.get_napi_version(), // non-zero numeric, undefined if unsupported | ||
napi_build_version: napi_build_version, // undefined if not specified | ||
node_abi_napi: napi.get_napi_version(options.target) ? 'napi' : get_runtime_abi(runtime,options.target), | ||
napi_version: napi.get_napi_version(options.target), // non-zero numeric, undefined if unsupported | ||
napi_build_version: napi_build_version || '', | ||
node_napi_label: napi_build_version ? 'napi-v' + napi_build_version : get_runtime_abi(runtime,options.target), | ||
target: options.target || '', | ||
@@ -304,0 +305,0 @@ platform: options.target_platform || process.platform, |
{ | ||
"_args": [ | ||
[ | ||
"node-pre-gyp@0.9.1", | ||
"node-pre-gyp@0.13.0", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "node-pre-gyp@0.9.1", | ||
"_id": "node-pre-gyp@0.9.1", | ||
"_from": "node-pre-gyp@0.13.0", | ||
"_id": "node-pre-gyp@0.13.0", | ||
"_inBundle": false, | ||
"_integrity": "sha1-8RwHUW3ZL4cZnbx+GDjqt81WyeA=", | ||
"_integrity": "sha512-Md1D3xnEne8b/HGVQkZZwV27WUi1ZRuZBij24TNaZwUPU3ZAFtvT6xxJGaUVillfmMKnn5oD1HoGsp2Ftik7SQ==", | ||
"_location": "/node-pre-gyp", | ||
"_phantomChildren": {}, | ||
"_phantomChildren": { | ||
"abbrev": "1.1.1", | ||
"osenv": "0.1.5" | ||
}, | ||
"_requested": { | ||
"type": "version", | ||
"registry": true, | ||
"raw": "node-pre-gyp@0.9.1", | ||
"raw": "node-pre-gyp@0.13.0", | ||
"name": "node-pre-gyp", | ||
"escapedName": "node-pre-gyp", | ||
"rawSpec": "0.9.1", | ||
"rawSpec": "0.13.0", | ||
"saveSpec": null, | ||
"fetchSpec": "0.9.1" | ||
"fetchSpec": "0.13.0" | ||
}, | ||
@@ -27,4 +30,4 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.9.1.tgz", | ||
"_spec": "0.9.1", | ||
"_resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.13.0.tgz", | ||
"_spec": "0.13.0", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -44,7 +47,7 @@ "author": { | ||
"mkdirp": "^0.5.1", | ||
"needle": "^2.2.0", | ||
"needle": "^2.2.1", | ||
"nopt": "^4.0.1", | ||
"npm-packlist": "^1.1.6", | ||
"npmlog": "^4.0.2", | ||
"rc": "^1.1.7", | ||
"rc": "^1.2.7", | ||
"rimraf": "^2.6.1", | ||
@@ -59,3 +62,2 @@ "semver": "^5.3.0", | ||
"nock": "^9.2.3", | ||
"retire": "^1.2.12", | ||
"tape": "^4.6.3" | ||
@@ -92,3 +94,3 @@ }, | ||
}, | ||
"version": "0.9.1" | ||
"version": "0.13.0" | ||
} |
@@ -33,3 +33,3 @@ # node-pre-gyp | ||
- Node.js >= node v4.x | ||
- Node.js >= node v6.x | ||
@@ -86,3 +86,3 @@ ## Install | ||
- `myapp` is referenced in the package.json of a larger app and therefore `myapp` is being installed as a dependent with `npm install`. | ||
- `myapp` is referenced in the package.json of a larger app and therefore `myapp` is being installed as a dependency with `npm install`. | ||
- The larger app also depends on other modules installed with `node-pre-gyp` | ||
@@ -111,3 +111,2 @@ - You only want to trigger a source compile for `myapp` and the other modules. | ||
} | ||
"bundledDependencies":["node-pre-gyp"], | ||
"scripts": { | ||
@@ -129,8 +128,6 @@ "install": "node-pre-gyp install --fallback-to-build" | ||
- Your devDependencies should list `aws-sdk` so that you can run `node-pre-gyp publish` locally or a CI system. We recommend using `devDependencies` only since `aws-sdk` is large and not needed for `node-pre-gyp install` since it only uses http to fetch binaries | ||
- You should add `"bundledDependencies":["node-pre-gyp"]`. This ensures that when you publish your module that the correct version of node-pre-gyp will be included in the `node_modules` folder during publishing. Then when uses install your module `node-pre-gyp` will already be present. Without this your module will not be safely installable for downstream applications that have a depedency on node-pre-gyp in the npm tree (without bundling npm deduping might break the install when node-pre-gyp is moved in flight) | ||
- Your `scripts` section should optionally add `"prepublishOnly": "npm ls"` to ensure the right node-pre-gyp version is bundled before publishing your module. If node-pre-gyp is missing or an old version is present then this will catch that error before you publish a broken package. | ||
- Your `scripts` section should override the `install` target with `"install": "node-pre-gyp install --fallback-to-build"`. This allows node-pre-gyp to be used instead of the default npm behavior of always source compiling with `node-gyp` directly. | ||
- Your package.json should contain a `binary` section describing key properties you provide to allow node-pre-gyp to package optimally. They are detailed below. | ||
Note: in the past we recommended using `"preinstall": "npm install node-pre-gyp"` as an alternative method to avoid needing to bundle. But this does not behave predictably across all npm versions - see https://github.com/mapbox/node-pre-gyp/issues/260 for the details. So we do not recommend using `preinstall` to install `node-pre-gyp`. Instead we recommend bundling. More history on this at https://github.com/strongloop/fsevents/issues/157#issuecomment-265545908. | ||
Note: in the past we recommended putting `node-pre-gyp` in the `bundledDependencies`, but we no longer recommend this. In the past there were npm bugs (with node versions 0.10.x) that could lead to node-pre-gyp not being available at the right time during install (unless we bundled). This should no longer be the case. Also, for a time we recommended using `"preinstall": "npm install node-pre-gyp"` as an alternative method to avoid needing to bundle. But this did not behave predictably across all npm versions - see https://github.com/mapbox/node-pre-gyp/issues/260 for the details. So we do not recommend using `preinstall` to install `node-pre-gyp`. More history on this at https://github.com/strongloop/fsevents/issues/157#issuecomment-265545908. | ||
@@ -163,3 +160,3 @@ ##### The `binary` object has three required properties | ||
Why then not require S3? Because while some applications using node-pre-gyp need to distribute binaries as large as 20-30 MB, others might have very small binaries and might wish to store them in a GitHub repo. This is not recommended, but if an author really wants to host in a non-s3 location then it should be possible. | ||
Why then not require S3? Because while some applications using node-pre-gyp need to distribute binaries as large as 20-30 MB, others might have very small binaries and might wish to store them in a GitHub repo. This is not recommended, but if an author really wants to host in a non-S3 location then it should be possible. | ||
@@ -295,7 +292,7 @@ It should also be mentioned that there is an optional and entirely separate npm module called [node-pre-gyp-github](https://github.com/bchr02/node-pre-gyp-github) which is intended to complement node-pre-gyp and be installed along with it. It provides the ability to store and publish your binaries within your repositories GitHub Releases if you would rather not use S3 directly. Installation and usage instructions can be found [here](https://github.com/bchr02/node-pre-gyp-github), but the basic premise is that instead of using the ```node-pre-gyp publish``` command you would use ```node-pre-gyp-github publish```. | ||
[N-API](https://nodejs.org/api/n-api.html#n_api_n_api) is an ABI-stable alternative to previous technologies such as [nan](https://github.com/nodejs/nan) which are tied to a specific Node runtime engine. N-API is Node runtime engine agnostic and guarantees modules created today will continue to run, without changes, into the future. | ||
[N-API](https://nodejs.org/api/n-api.html#n_api_n_api) is an ABI-stable alternative to previous technologies such as [nan](https://github.com/nodejs/nan) which are tied to a specific Node runtime engine. N-API is Node runtime engine agnostic and guarantees modules created today will continue to run, without changes, into the future. | ||
Using `node-pre-gyp` with N-API projects requires a handful of additional configuration values and imposes some additional requirements. | ||
Using `node-pre-gyp` with N-API projects requires a handful of additional configuration values and imposes some additional requirements. | ||
The most significant difference is that an N-API module can be coded to target multiple N-API versions. Therefore, an N-API module must declare in its `package.json` file which N-API versions the module is designed to run against. In addition, since multiple builds may be required for a single module, path and file names must be specified in way that avoids naming conflicts. | ||
The most significant difference is that an N-API module can be coded to target multiple N-API versions. Therefore, an N-API module must declare in its `package.json` file which N-API versions the module is designed to run against. In addition, since multiple builds may be required for a single module, path and file names must be specified in way that avoids naming conflicts. | ||
@@ -317,7 +314,7 @@ ### The `napi_versions` array property | ||
When the `napi_versions` array property is present, `node-pre-gyp` fires off multiple operations, one for each of the N-API versions in the array. In the example above, two operations are initiated, one for N-API version 1 and second for N-API version 3. How this version number is communicated is described next. | ||
When the `napi_versions` array property is present, `node-pre-gyp` fires off multiple operations, one for each of the N-API versions in the array. In the example above, two operations are initiated, one for N-API version 1 and second for N-API version 3. How this version number is communicated is described next. | ||
### The `napi_build_version` value | ||
For each of the N-API module operations `node-pre-gyp` initiates, it insures that the `napi_build_version` is set appropriately. | ||
For each of the N-API module operations `node-pre-gyp` initiates, it ensures that the `napi_build_version` is set appropriately. | ||
@@ -327,5 +324,5 @@ This value is of importance in two areas: | ||
1. The C/C++ code which needs to know against which N-API version it should compile. | ||
2. `node-pre-gyp` itself which must assign appropriate path and file names to avoid collisions. | ||
2. `node-pre-gyp` itself which must assign appropriate path and file names to avoid collisions. | ||
### Defining `NAPI_BUILD_VERSION` for the C/C++ code | ||
### Defining `NAPI_VERSION` for the C/C++ code | ||
@@ -336,13 +333,15 @@ The `napi_build_version` value is communicated to the C/C++ code by adding this code to the `binding.gyp` file: | ||
"defines": [ | ||
"NAPI_BUILD_VERSION=<(napi_build_version)", | ||
"NAPI_VERSION=<(napi_build_version)", | ||
] | ||
``` | ||
This insures that `NAPI_BUILD_VERSION`, an integer value, is declared appropriately to the C/C++ code for each build. | ||
This ensures that `NAPI_VERSION`, an integer value, is declared appropriately to the C/C++ code for each build. | ||
> Note that earlier versions of this document recommended defining the symbol `NAPI_BUILD_VERSION`. `NAPI_VERSION` is prefered because it used by the N-API C/C++ headers to configure the specific N-API veriosn being requested. | ||
### Path and file naming requirements in `package.json` | ||
Since `node-pre-gyp` fires off multiple operations for each request, it is essential that path and file names be created in such a way as to avoid collisions. This is accomplished by imposing additional path and file naming requirements. | ||
Since `node-pre-gyp` fires off multiple operations for each request, it is essential that path and file names be created in such a way as to avoid collisions. This is accomplished by imposing additional path and file naming requirements. | ||
Specifically, when performing N-API builds, the `{napi_build_version}` text substitution string *must* be present in the `module_path` property. In addition, the `{napi_build_version}` text substitution string *must* be present in either the `remote_path` or `package_name` property. (No problem if it's in both.) | ||
Specifically, when performing N-API builds, the `{napi_build_version}` text configuration value *must* be present in the `module_path` property. In addition, the `{napi_build_version}` text configuration value *must* be present in either the `remote_path` or `package_name` property. (No problem if it's in both.) | ||
@@ -362,11 +361,44 @@ Here's an example: | ||
## Supporting both N-API and NAN builds | ||
You may have a legacy native add-on that you wish to continue supporting for those versions of Node that do not support N-API, as you add N-API support for later Node versions. This can be accomplished by specifying the `node_napi_label` configuration value in the package.json `binary.package_name` property. | ||
Placing the configuration value `node_napi_label` in the package.json `binary.package_name` property instructs `node-pre-gyp` to build all viable N-API binaries supported by the current Node instance. If the current Node instance does not support N-API, `node-pre-gyp` will request a traditional, non-N-API build. | ||
The configuration value `node_napi_label` is set by `node-pre-gyp` to the type of build created, `napi` or `node`, and the version number. For N-API builds, the string contains the N-API version nad has values like `napi-v3`. For traditional, non-N-API builds, the string contains the ABI version with values like `node-v46`. | ||
Here's how the `binary` configuration above might be changed to support both N-API and NAN builds: | ||
```js | ||
"binary": { | ||
"module_name": "your_module", | ||
"module_path": "./lib/binding/{node_napi_label}", | ||
"remote_path": "./{module_name}/v{version}/{configuration}/", | ||
"package_name": "{platform}-{arch}-{node_napi_label}.tar.gz", | ||
"host": "https://your_bucket.s3-us-west-1.amazonaws.com", | ||
"napi_versions": [1,3] | ||
} | ||
``` | ||
The C/C++ symbol `NAPI_VERSION` can be used to distinguish N-API and non-N-API builds. The value of `NAPI_VERSION` is set to the integer N-API version for N-API builds and is set to `0` for non-N-API builds. | ||
For example: | ||
```C | ||
#if NAPI_VERSION | ||
// N-API code goes here | ||
#else | ||
// NAN code goes here | ||
#endif | ||
``` | ||
### Two additional configuration values | ||
For those who need them in legacy projects, two additional configuration values are available for all builds. | ||
The following two configuration values, which were implemented in previous versions of `node-pre-gyp`, continue to exist, but have been replaced by the `node_napi_label` configuration value described above. | ||
1. `napi_version` If N-API is supported by the currently executing Node instance, this value is the N-API version number supported by Node. If N-API is not supported, this value is an empty string. | ||
1. `napi_version` If N-API is supported by the currently executing Node instance, this value is the N-API version number supported by Node. If N-API is not supported, this value is an empty string. | ||
2. `node_abi_napi` If the value returned for `napi_version` is non empty, this value is `'napi'`. If the value returned for `napi_version` is empty, this value is the value returned for `node_abi`. | ||
These values are present for use in the `binding.gyp` file and may be used as `{napi_version}` and `{node_abi_napi}` for text substituion in the `binary` properties of the `package.json` file. | ||
These values are present for use in the `binding.gyp` file and may be used as `{napi_version}` and `{node_abi_napi}` for text substituion in the `binary` properties of the `package.json` file. | ||
@@ -373,0 +405,0 @@ ## S3 Hosting |
@@ -46,2 +46,14 @@ 'use strict' | ||
addListener (ev, fn) { | ||
return this.on(ev, fn) | ||
} | ||
on (ev, fn) { | ||
const ret = super.on(ev, fn) | ||
if (ev === 'done' && this.didDone) { | ||
this.emit('done', this.result) | ||
} | ||
return ret | ||
} | ||
done () { | ||
@@ -61,3 +73,3 @@ if (!this.didDone) { | ||
start () { | ||
const pj = this.path + '/package.json' | ||
const pj = path.resolve(this.path, 'package.json') | ||
if (this.packageJsonCache.has(pj)) | ||
@@ -64,0 +76,0 @@ this.onPackage(this.packageJsonCache.get(pj)) |
{ | ||
"_args": [ | ||
[ | ||
"npm-bundled@1.0.5", | ||
"npm-bundled@1.0.6", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "npm-bundled@1.0.5", | ||
"_id": "npm-bundled@1.0.5", | ||
"_from": "npm-bundled@1.0.6", | ||
"_id": "npm-bundled@1.0.6", | ||
"_inBundle": false, | ||
"_integrity": "sha512-m/e6jgWu8/v5niCUKQi9qQl8QdeEduFA96xHDDzFGqly0OOjI7c+60KM/2sppfnUU9JJagf+zs+yGhqSOFj71g==", | ||
"_integrity": "sha512-8/JCaftHwbd//k6y2rEWp6k1wxVfpFzB6t1p825+cUb7Ym2XQfhwIC5KwhrvzZRJu+LtDE585zVaS32+CGtf0g==", | ||
"_location": "/npm-bundled", | ||
@@ -17,8 +17,8 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "npm-bundled@1.0.5", | ||
"raw": "npm-bundled@1.0.6", | ||
"name": "npm-bundled", | ||
"escapedName": "npm-bundled", | ||
"rawSpec": "1.0.5", | ||
"rawSpec": "1.0.6", | ||
"saveSpec": null, | ||
"fetchSpec": "1.0.5" | ||
"fetchSpec": "1.0.6" | ||
}, | ||
@@ -28,4 +28,4 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.5.tgz", | ||
"_spec": "1.0.5", | ||
"_resolved": "https://registry.npmjs.org/npm-bundled/-/npm-bundled-1.0.6.tgz", | ||
"_spec": "1.0.6", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -64,3 +64,3 @@ "author": { | ||
}, | ||
"version": "1.0.5" | ||
"version": "1.0.6" | ||
} |
@@ -23,6 +23,10 @@ 'use strict' | ||
'.gitignore', | ||
'**/.git/', | ||
'**/.svn/', | ||
'**/.hg/', | ||
'**/CVS/', | ||
'**/.git', | ||
'**/.svn', | ||
'**/.hg', | ||
'**/CVS', | ||
'**/.git/**', | ||
'**/.svn/**', | ||
'**/.hg/**', | ||
'**/CVS/**', | ||
'/.lock-wscript', | ||
@@ -34,6 +38,16 @@ '/.wafpickle-*', | ||
'.*.swp', | ||
'.DS_Store', | ||
'**/.DS_Store/**', | ||
'._*', | ||
'**/._*/**', | ||
'*.orig', | ||
'package-lock.json' | ||
'/package-lock.json', | ||
'/yarn.lock', | ||
'archived-packages/**', | ||
'core', | ||
'!core/', | ||
'!**/core/', | ||
'*.core', | ||
'*.vgcore', | ||
'vgcore.*', | ||
'core.+([0-9])', | ||
] | ||
@@ -57,3 +71,7 @@ | ||
opt.path = opt.path || process.cwd() | ||
opt.follow = path.basename(opt.path) === 'node_modules' | ||
const dirName = path.basename(opt.path) | ||
const parentName = path.basename(path.dirname(opt.path)) | ||
opt.follow = | ||
dirName === 'node_modules' || | ||
(parentName === 'node_modules' && /^@/.test(dirName)) | ||
super(opt) | ||
@@ -133,10 +151,20 @@ | ||
// if there's a browser or main, make sure we don't ignore it | ||
// if there's a bin, browser or main, make sure we don't ignore it | ||
// also, don't ignore the package.json itself! | ||
const rules = [ | ||
pkg.browser ? '!' + pkg.browser : '', | ||
pkg.main ? '!' + pkg.main : '', | ||
'!@(readme|license|licence|notice|changes|changelog|history){,.*}' | ||
].filter(f => f).join('\n') + '\n' | ||
super.onReadIgnoreFile(packageNecessaryRules, rules, _=>_) | ||
'!package.json', | ||
'!@(readme|copying|license|licence|notice|changes|changelog|history){,.*[^~$]}' | ||
] | ||
if (pkg.bin) | ||
if (typeof pkg.bin === "object") | ||
for (const key in pkg.bin) | ||
rules.push('!' + pkg.bin[key]) | ||
else | ||
rules.push('!' + pkg.bin) | ||
const data = rules.filter(f => f).join('\n') + '\n' | ||
super.onReadIgnoreFile(packageNecessaryRules, data, _=>_) | ||
if (Array.isArray(pkg.files)) | ||
@@ -161,3 +189,4 @@ super.onReadIgnoreFile('package.json', '*\n' + pkg.files.map( | ||
try { | ||
this.onPackageJson(file, JSON.parse(data), then) | ||
const ig = path.resolve(this.path, file) | ||
this.onPackageJson(ig, JSON.parse(data), then) | ||
} catch (er) { | ||
@@ -192,3 +221,3 @@ // ignore package.json files that are not json | ||
const p = new Promise((resolve, reject) => { | ||
const bw = new BundleWalker(options).start() | ||
const bw = new BundleWalker(options) | ||
bw.on('done', bundled => { | ||
@@ -199,2 +228,3 @@ options.bundled = bundled | ||
}) | ||
bw.start() | ||
}) | ||
@@ -201,0 +231,0 @@ return callback ? p.then(res => callback(null, res), callback) : p |
{ | ||
"_args": [ | ||
[ | ||
"npm-packlist@1.1.11", | ||
"npm-packlist@1.4.1", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "npm-packlist@1.1.11", | ||
"_id": "npm-packlist@1.1.11", | ||
"_from": "npm-packlist@1.4.1", | ||
"_id": "npm-packlist@1.4.1", | ||
"_inBundle": false, | ||
"_integrity": "sha512-CxKlZ24urLkJk+9kCm48RTQ7L4hsmgSVzEk0TLGPzzyuFxD7VNgy5Sl24tOLMzQv773a/NeJ1ce1DKeacqffEA==", | ||
"_integrity": "sha512-+TcdO7HJJ8peiiYhvPxsEDhF3PJFGUGRcFsGve3vxvxdcpO2Z4Z7rkosRM0kWj6LfbK/P0gu3dzk5RU1ffvFcw==", | ||
"_location": "/npm-packlist", | ||
@@ -17,8 +17,8 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "npm-packlist@1.1.11", | ||
"raw": "npm-packlist@1.4.1", | ||
"name": "npm-packlist", | ||
"escapedName": "npm-packlist", | ||
"rawSpec": "1.1.11", | ||
"rawSpec": "1.4.1", | ||
"saveSpec": null, | ||
"fetchSpec": "1.1.11" | ||
"fetchSpec": "1.4.1" | ||
}, | ||
@@ -28,4 +28,4 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.1.11.tgz", | ||
"_spec": "1.1.11", | ||
"_resolved": "https://registry.npmjs.org/npm-packlist/-/npm-packlist-1.4.1.tgz", | ||
"_spec": "1.4.1", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -70,3 +70,3 @@ "author": { | ||
}, | ||
"version": "1.1.11" | ||
"version": "1.4.1" | ||
} |
{ | ||
"_args": [ | ||
[ | ||
"rimraf@2.6.2", | ||
"rimraf@2.6.3", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "rimraf@2.6.2", | ||
"_id": "rimraf@2.6.2", | ||
"_from": "rimraf@2.6.3", | ||
"_id": "rimraf@2.6.3", | ||
"_inBundle": false, | ||
"_integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", | ||
"_integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", | ||
"_location": "/rimraf", | ||
@@ -17,18 +17,21 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "rimraf@2.6.2", | ||
"raw": "rimraf@2.6.3", | ||
"name": "rimraf", | ||
"escapedName": "rimraf", | ||
"rawSpec": "2.6.2", | ||
"rawSpec": "2.6.3", | ||
"saveSpec": null, | ||
"fetchSpec": "2.6.2" | ||
"fetchSpec": "2.6.3" | ||
}, | ||
"_requiredBy": [ | ||
"#DEV:/", | ||
"/fstream", | ||
"/istanbul-lib-processinfo", | ||
"/istanbul-lib-source-maps", | ||
"/node-gyp", | ||
"/node-pre-gyp", | ||
"/nyc", | ||
"/spawn-wrap", | ||
"/tap" | ||
], | ||
"_resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", | ||
"_spec": "2.6.2", | ||
"_resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", | ||
"_spec": "2.6.3", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -47,3 +50,3 @@ "author": { | ||
"dependencies": { | ||
"glob": "^7.0.5" | ||
"glob": "^7.1.3" | ||
}, | ||
@@ -53,3 +56,3 @@ "description": "A deep deletion module for node (like `rm -rf`)", | ||
"mkdirp": "^0.5.1", | ||
"tap": "^10.1.2" | ||
"tap": "^12.1.1" | ||
}, | ||
@@ -71,5 +74,8 @@ "files": [ | ||
"scripts": { | ||
"postpublish": "git push origin --all; git push origin --tags", | ||
"postversion": "npm publish", | ||
"preversion": "npm test", | ||
"test": "tap test/*.js" | ||
}, | ||
"version": "2.6.2" | ||
"version": "2.6.3" | ||
} |
{ | ||
"_args": [ | ||
[ | ||
"semver@5.5.1", | ||
"semver@5.3.0", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "semver@5.5.1", | ||
"_id": "semver@5.5.1", | ||
"_from": "semver@5.3.0", | ||
"_id": "semver@5.3.0", | ||
"_inBundle": false, | ||
"_integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==", | ||
"_integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", | ||
"_location": "/semver", | ||
@@ -17,14 +17,16 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "semver@5.5.1", | ||
"raw": "semver@5.3.0", | ||
"name": "semver", | ||
"escapedName": "semver", | ||
"rawSpec": "5.5.1", | ||
"rawSpec": "5.3.0", | ||
"saveSpec": null, | ||
"fetchSpec": "5.5.1" | ||
"fetchSpec": "5.3.0" | ||
}, | ||
"_requiredBy": [ | ||
"/node-pre-gyp" | ||
"/node-gyp", | ||
"/node-pre-gyp", | ||
"/normalize-package-data" | ||
], | ||
"_resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", | ||
"_spec": "5.5.1", | ||
"_resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", | ||
"_spec": "5.3.0", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -39,3 +41,3 @@ "bin": { | ||
"devDependencies": { | ||
"tap": "^12.0.1" | ||
"tap": "^2.0.0" | ||
}, | ||
@@ -56,5 +58,5 @@ "files": [ | ||
"scripts": { | ||
"test": "tap test/*.js --cov -J" | ||
"test": "tap test/*.js" | ||
}, | ||
"version": "5.5.1" | ||
"version": "5.3.0" | ||
} |
semver(1) -- The semantic versioner for npm | ||
=========================================== | ||
## Install | ||
```bash | ||
npm install --save semver | ||
```` | ||
## Usage | ||
As a node module: | ||
$ npm install semver | ||
$ node | ||
var semver = require('semver') | ||
```js | ||
const semver = require('semver') | ||
semver.valid('1.2.3') // '1.2.3' | ||
semver.valid('a.b.c') // null | ||
semver.clean(' =v1.2.3 ') // '1.2.3' | ||
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true | ||
semver.gt('1.2.3', '9.8.7') // false | ||
semver.lt('1.2.3', '9.8.7') // true | ||
semver.valid('1.2.3') // '1.2.3' | ||
semver.valid('a.b.c') // null | ||
semver.clean(' =v1.2.3 ') // '1.2.3' | ||
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true | ||
semver.gt('1.2.3', '9.8.7') // false | ||
semver.lt('1.2.3', '9.8.7') // true | ||
semver.valid(semver.coerce('v2')) // '2.0.0' | ||
semver.valid(semver.coerce('42.6.7.9.3-alpha')) // '42.6.7' | ||
``` | ||
As a command-line utility: | ||
``` | ||
$ semver -h | ||
$ semver -h | ||
SemVer 5.3.0 | ||
SemVer 5.1.0 | ||
A JavaScript implementation of the http://semver.org/ specification | ||
Copyright Isaac Z. Schlueter | ||
A JavaScript implementation of the http://semver.org/ specification | ||
Copyright Isaac Z. Schlueter | ||
Usage: semver [options] <version> [<version> [...]] | ||
Prints valid versions sorted by SemVer precedence | ||
Usage: semver [options] <version> [<version> [...]] | ||
Prints valid versions sorted by SemVer precedence | ||
Options: | ||
-r --range <range> | ||
Print versions that match the specified range. | ||
Options: | ||
-r --range <range> | ||
Print versions that match the specified range. | ||
-i --increment [<level>] | ||
Increment a version by the specified level. Level can | ||
be one of: major, minor, patch, premajor, preminor, | ||
prepatch, or prerelease. Default level is 'patch'. | ||
Only one version may be specified. | ||
-i --increment [<level>] | ||
Increment a version by the specified level. Level can | ||
be one of: major, minor, patch, premajor, preminor, | ||
prepatch, or prerelease. Default level is 'patch'. | ||
Only one version may be specified. | ||
--preid <identifier> | ||
Identifier to be used to prefix premajor, preminor, | ||
prepatch or prerelease version increments. | ||
--preid <identifier> | ||
Identifier to be used to prefix premajor, preminor, | ||
prepatch or prerelease version increments. | ||
-l --loose | ||
Interpret versions and ranges loosely | ||
-l --loose | ||
Interpret versions and ranges loosely | ||
-c --coerce | ||
Coerce a string into SemVer if possible | ||
(does not imply --loose) | ||
Program exits successfully if any valid version satisfies | ||
all supplied ranges, and prints all satisfying versions. | ||
Program exits successfully if any valid version satisfies | ||
all supplied ranges, and prints all satisfying versions. | ||
If no satisfying versions are found, then exits failure. | ||
If no satisfying versions are found, then exits failure. | ||
Versions are printed in ascending order, so supplying | ||
multiple versions to the utility will just sort them. | ||
Versions are printed in ascending order, so supplying | ||
multiple versions to the utility will just sort them. | ||
``` | ||
## Versions | ||
@@ -145,4 +129,4 @@ | ||
```javascript | ||
semver.inc('1.2.3', 'prerelease', 'beta') | ||
// '1.2.4-beta.0' | ||
> semver.inc('1.2.3', 'prerelease', 'beta') | ||
'1.2.4-beta.0' | ||
``` | ||
@@ -152,3 +136,3 @@ | ||
```bash | ||
```shell | ||
$ semver 1.2.3 -i prerelease --preid beta | ||
@@ -160,3 +144,3 @@ 1.2.4-beta.0 | ||
```bash | ||
```shell | ||
$ semver 1.2.4-beta.0 -i prerelease | ||
@@ -280,3 +264,3 @@ 1.2.4-beta.1 | ||
simple ::= primitive | partial | tilde | caret | ||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial | ||
primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | ) partial | ||
partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? | ||
@@ -319,4 +303,2 @@ xr ::= 'x' | 'X' | '*' | nr | ||
* `patch(v)`: Return the patch version number. | ||
* `intersects(r1, r2, loose)`: Return true if the two supplied ranges | ||
or comparators intersect. | ||
@@ -345,6 +327,3 @@ ### Comparison | ||
### Comparators | ||
* `intersects(comparator)`: Return true if the comparators intersect | ||
### Ranges | ||
@@ -367,3 +346,2 @@ | ||
the function called by `gtr` and `ltr`.) | ||
* `intersects(range)`: Return true if any of the ranges comparators intersect | ||
@@ -380,17 +358,1 @@ Note that, since ranges may be non-contiguous, a version might not be | ||
range, use the `satisfies(version, range)` function. | ||
### Coercion | ||
* `coerce(version)`: Coerces a string to semver if possible | ||
This aims to provide a very forgiving translation of a non-semver | ||
string to semver. It looks for the first digit in a string, and | ||
consumes all remaining characters which satisfy at least a partial semver | ||
(e.g., `1`, `1.2`, `1.2.3`) up to the max permitted length (256 characters). | ||
Longer versions are simply truncated (`4.6.3.9.2-alpha2` becomes `4.6.3`). | ||
All surrounding text is simply ignored (`v3.4 replaces v3.3.1` becomes `3.4.0`). | ||
Only text which lacks digits will fail coercion (`version one` is not valid). | ||
The maximum length for any semver component considered for coercion is 16 characters; | ||
longer components will be ignored (`10000000000000000.4.7.4` becomes `4.7.4`). | ||
The maximum value for any semver component is `Integer.MAX_SAFE_INTEGER || (2**53 - 1)`; | ||
higher value components are invalid (`9999999999999999.4.7.4` is likely invalid). |
@@ -24,5 +24,2 @@ exports = module.exports = SemVer; | ||
// Max safe segment length for coercion. | ||
var MAX_SAFE_COMPONENT_LENGTH = 16; | ||
// The actual regexps go on exports.re | ||
@@ -163,11 +160,2 @@ var re = exports.re = []; | ||
// Coercion. | ||
// Extract anything that could conceivably be a part of a valid semver | ||
var COERCE = R++; | ||
src[COERCE] = '(?:^|[^\\d])' + | ||
'(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' + | ||
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + | ||
'(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' + | ||
'(?:$|[^\\d])'; | ||
// Tilde ranges. | ||
@@ -580,3 +568,3 @@ // Meaning is "reasonably at or greater than" | ||
function compare(a, b, loose) { | ||
return new SemVer(a, loose).compare(new SemVer(b, loose)); | ||
return new SemVer(a, loose).compare(b); | ||
} | ||
@@ -722,56 +710,8 @@ | ||
Comparator.prototype.intersects = function(comp, loose) { | ||
if (!(comp instanceof Comparator)) { | ||
throw new TypeError('a Comparator is required'); | ||
} | ||
var rangeTmp; | ||
if (this.operator === '') { | ||
rangeTmp = new Range(comp.value, loose); | ||
return satisfies(this.value, rangeTmp, loose); | ||
} else if (comp.operator === '') { | ||
rangeTmp = new Range(this.value, loose); | ||
return satisfies(comp.semver, rangeTmp, loose); | ||
} | ||
var sameDirectionIncreasing = | ||
(this.operator === '>=' || this.operator === '>') && | ||
(comp.operator === '>=' || comp.operator === '>'); | ||
var sameDirectionDecreasing = | ||
(this.operator === '<=' || this.operator === '<') && | ||
(comp.operator === '<=' || comp.operator === '<'); | ||
var sameSemVer = this.semver.version === comp.semver.version; | ||
var differentDirectionsInclusive = | ||
(this.operator === '>=' || this.operator === '<=') && | ||
(comp.operator === '>=' || comp.operator === '<='); | ||
var oppositeDirectionsLessThan = | ||
cmp(this.semver, '<', comp.semver, loose) && | ||
((this.operator === '>=' || this.operator === '>') && | ||
(comp.operator === '<=' || comp.operator === '<')); | ||
var oppositeDirectionsGreaterThan = | ||
cmp(this.semver, '>', comp.semver, loose) && | ||
((this.operator === '<=' || this.operator === '<') && | ||
(comp.operator === '>=' || comp.operator === '>')); | ||
return sameDirectionIncreasing || sameDirectionDecreasing || | ||
(sameSemVer && differentDirectionsInclusive) || | ||
oppositeDirectionsLessThan || oppositeDirectionsGreaterThan; | ||
}; | ||
exports.Range = Range; | ||
function Range(range, loose) { | ||
if (range instanceof Range) { | ||
if (range.loose === loose) { | ||
return range; | ||
} else { | ||
return new Range(range.raw, loose); | ||
} | ||
} | ||
if ((range instanceof Range) && range.loose === loose) | ||
return range; | ||
if (range instanceof Comparator) { | ||
return new Range(range.value, loose); | ||
} | ||
if (!(this instanceof Range)) | ||
@@ -850,18 +790,2 @@ return new Range(range, loose); | ||
Range.prototype.intersects = function(range, loose) { | ||
if (!(range instanceof Range)) { | ||
throw new TypeError('a Range is required'); | ||
} | ||
return this.set.some(function(thisComparators) { | ||
return thisComparators.every(function(thisComparator) { | ||
return range.set.some(function(rangeComparators) { | ||
return rangeComparators.every(function(rangeComparator) { | ||
return thisComparator.intersects(rangeComparator, loose); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}; | ||
// Mostly just for testing and legacy API reasons | ||
@@ -1171,18 +1095,7 @@ exports.toComparators = toComparators; | ||
function maxSatisfying(versions, range, loose) { | ||
var max = null; | ||
var maxSV = null; | ||
try { | ||
var rangeObj = new Range(range, loose); | ||
} catch (er) { | ||
return null; | ||
} | ||
versions.forEach(function (v) { | ||
if (rangeObj.test(v)) { // satisfies(v, range, loose) | ||
if (!max || maxSV.compare(v) === -1) { // compare(max, v, true) | ||
max = v; | ||
maxSV = new SemVer(max, loose); | ||
} | ||
} | ||
}) | ||
return max; | ||
return versions.filter(function(version) { | ||
return satisfies(version, range, loose); | ||
}).sort(function(a, b) { | ||
return rcompare(a, b, loose); | ||
})[0] || null; | ||
} | ||
@@ -1192,18 +1105,7 @@ | ||
function minSatisfying(versions, range, loose) { | ||
var min = null; | ||
var minSV = null; | ||
try { | ||
var rangeObj = new Range(range, loose); | ||
} catch (er) { | ||
return null; | ||
} | ||
versions.forEach(function (v) { | ||
if (rangeObj.test(v)) { // satisfies(v, range, loose) | ||
if (!min || minSV.compare(v) === 1) { // compare(min, v, true) | ||
min = v; | ||
minSV = new SemVer(min, loose); | ||
} | ||
} | ||
}) | ||
return min; | ||
return versions.filter(function(version) { | ||
return satisfies(version, range, loose); | ||
}).sort(function(a, b) { | ||
return compare(a, b, loose); | ||
})[0] || null; | ||
} | ||
@@ -1309,24 +1211,1 @@ | ||
} | ||
exports.intersects = intersects; | ||
function intersects(r1, r2, loose) { | ||
r1 = new Range(r1, loose) | ||
r2 = new Range(r2, loose) | ||
return r1.intersects(r2) | ||
} | ||
exports.coerce = coerce; | ||
function coerce(version) { | ||
if (version instanceof SemVer) | ||
return version; | ||
if (typeof version !== 'string') | ||
return null; | ||
var match = version.match(re[COERCE]); | ||
if (match == null) | ||
return null; | ||
return parse((match[1] || '0') + '.' + (match[2] || '0') + '.' + (match[3] || '0')); | ||
} |
@@ -32,2 +32,3 @@ 'use strict' | ||
const zlib = require('minizlib') | ||
const Buffer = require('./buffer.js') | ||
@@ -34,0 +35,0 @@ const gzipHeader = Buffer.from([0x1f, 0x8b]) |
@@ -181,2 +181,8 @@ 'use strict' | ||
entry.path = parts.slice(this.strip).join('/') | ||
if (entry.type === 'Link') { | ||
const linkparts = entry.linkpath.split(/\/|\\/) | ||
if (linkparts.length >= this.strip) | ||
entry.linkpath = linkparts.slice(this.strip).join('/') | ||
} | ||
} | ||
@@ -183,0 +189,0 @@ |
@@ -230,9 +230,19 @@ 'use strict' | ||
if (bytesRead <= 0 && remain > 0) { | ||
const er = new Error('unexpected EOF') | ||
const er = new Error('encountered unexpected EOF') | ||
er.path = this.absolute | ||
er.syscall = 'read' | ||
er.code = 'EOF' | ||
this.emit('error', er) | ||
this[CLOSE](fd) | ||
return this.emit('error', er) | ||
} | ||
if (bytesRead > remain) { | ||
const er = new Error('did not encounter expected EOF') | ||
er.path = this.absolute | ||
er.syscall = 'read' | ||
er.code = 'EOF' | ||
this[CLOSE](fd) | ||
return this.emit('error', er) | ||
} | ||
// null out the rest of the buffer, if we could fit the block padding | ||
@@ -239,0 +249,0 @@ if (bytesRead === remain) { |
{ | ||
"_args": [ | ||
[ | ||
"tar@4.4.6", | ||
"tar@4.4.8", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "tar@4.4.6", | ||
"_id": "tar@4.4.6", | ||
"_from": "tar@4.4.8", | ||
"_id": "tar@4.4.8", | ||
"_inBundle": false, | ||
"_integrity": "sha512-tMkTnh9EdzxyfW+6GK6fCahagXsnYk6kE6S9Gr9pjVdys769+laCTbodXDhPAjzVtEBazRgP0gYqOjnk9dQzLg==", | ||
"_integrity": "sha512-LzHF64s5chPQQS0IYBn9IN5h3i98c12bo4NCO7e0sGM2llXQ3p2FGC5sdENN4cTW48O915Sh+x+EXx7XW96xYQ==", | ||
"_location": "/tar", | ||
@@ -17,14 +17,15 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "tar@4.4.6", | ||
"raw": "tar@4.4.8", | ||
"name": "tar", | ||
"escapedName": "tar", | ||
"rawSpec": "4.4.6", | ||
"rawSpec": "4.4.8", | ||
"saveSpec": null, | ||
"fetchSpec": "4.4.6" | ||
"fetchSpec": "4.4.8" | ||
}, | ||
"_requiredBy": [ | ||
"/node-gyp", | ||
"/node-pre-gyp" | ||
], | ||
"_resolved": "https://registry.npmjs.org/tar/-/tar-4.4.6.tgz", | ||
"_spec": "4.4.6", | ||
"_resolved": "https://registry.npmjs.org/tar/-/tar-4.4.8.tgz", | ||
"_spec": "4.4.8", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -40,6 +41,6 @@ "author": { | ||
"dependencies": { | ||
"chownr": "^1.0.1", | ||
"chownr": "^1.1.1", | ||
"fs-minipass": "^1.2.5", | ||
"minipass": "^2.3.3", | ||
"minizlib": "^1.1.0", | ||
"minipass": "^2.3.4", | ||
"minizlib": "^1.1.1", | ||
"mkdirp": "^0.5.0", | ||
@@ -51,3 +52,3 @@ "safe-buffer": "^5.1.2", | ||
"devDependencies": { | ||
"chmodr": "^1.0.2", | ||
"chmodr": "^1.2.0", | ||
"end-of-stream": "^1.4.1", | ||
@@ -58,4 +59,4 @@ "events-to-array": "^1.1.2", | ||
"tap": "^12.0.1", | ||
"tar-fs": "^1.16.2", | ||
"tar-stream": "^1.6.0" | ||
"tar-fs": "^1.16.3", | ||
"tar-stream": "^1.6.2" | ||
}, | ||
@@ -84,3 +85,3 @@ "engines": { | ||
}, | ||
"version": "4.4.6" | ||
"version": "4.4.8" | ||
} |
@@ -111,3 +111,3 @@ # node-tar | ||
['some', 'files', 'and', 'folders'] | ||
).pipe(fs.createWriteStream('my-tarball.tgz') | ||
).pipe(fs.createWriteStream('my-tarball.tgz')) | ||
``` | ||
@@ -114,0 +114,0 @@ |
'use strict' | ||
var Yallist = require('./yallist.js') | ||
Yallist.prototype[Symbol.iterator] = function* () { | ||
for (let walker = this.head; walker; walker = walker.next) { | ||
yield walker.value | ||
module.exports = function (Yallist) { | ||
Yallist.prototype[Symbol.iterator] = function* () { | ||
for (let walker = this.head; walker; walker = walker.next) { | ||
yield walker.value | ||
} | ||
} | ||
} |
{ | ||
"_args": [ | ||
[ | ||
"yallist@3.0.2", | ||
"yallist@3.0.3", | ||
"/home/sergey/test/monero-nodejs-libwallet" | ||
] | ||
], | ||
"_from": "yallist@3.0.2", | ||
"_id": "yallist@3.0.2", | ||
"_from": "yallist@3.0.3", | ||
"_id": "yallist@3.0.3", | ||
"_inBundle": false, | ||
"_integrity": "sha1-hFK0u36Dx8GI2AQcGoN8dz1ti7k=", | ||
"_integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", | ||
"_location": "/yallist", | ||
@@ -17,8 +17,8 @@ "_phantomChildren": {}, | ||
"registry": true, | ||
"raw": "yallist@3.0.2", | ||
"raw": "yallist@3.0.3", | ||
"name": "yallist", | ||
"escapedName": "yallist", | ||
"rawSpec": "3.0.2", | ||
"rawSpec": "3.0.3", | ||
"saveSpec": null, | ||
"fetchSpec": "3.0.2" | ||
"fetchSpec": "3.0.3" | ||
}, | ||
@@ -29,4 +29,4 @@ "_requiredBy": [ | ||
], | ||
"_resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.2.tgz", | ||
"_spec": "3.0.2", | ||
"_resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", | ||
"_spec": "3.0.3", | ||
"_where": "/home/sergey/test/monero-nodejs-libwallet", | ||
@@ -44,3 +44,3 @@ "author": { | ||
"devDependencies": { | ||
"tap": "^10.3.0" | ||
"tap": "^12.1.0" | ||
}, | ||
@@ -68,3 +68,3 @@ "directories": { | ||
}, | ||
"version": "3.0.2" | ||
"version": "3.0.3" | ||
} |
@@ -374,4 +374,4 @@ 'use strict' | ||
try { | ||
// add if support or Symbol.iterator is present | ||
require('./iterator.js') | ||
// add if support for Symbol.iterator is present | ||
require('./iterator.js')(Yallist) | ||
} catch (er) {} |
{ | ||
"name": "monero-nodejs-libwallet", | ||
"version": "0.3.7", | ||
"version": "0.3.9", | ||
"description": "Monero libwallet native addon. Under development at the moment", | ||
@@ -34,10 +34,10 @@ "main": "index.js", | ||
"dependencies": { | ||
"nan": "^2.13.2", | ||
"node-pre-gyp": "^0.9.1" | ||
"nan": "^2.14.0", | ||
"node-pre-gyp": "^0.13.0" | ||
}, | ||
"devDependencies": { | ||
"aws-sdk": "^2.244.1", | ||
"node-gyp": "^3.6.2", | ||
"rimraf": "^2.6.2", | ||
"tap": "^12.0.1" | ||
"aws-sdk": "^2.495.0", | ||
"node-gyp": "^4.0.0", | ||
"rimraf": "^2.6.3", | ||
"tap": "^14.4.2" | ||
}, | ||
@@ -44,0 +44,0 @@ "bundledDependencies": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 113 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
3
33192
28
16886965
587
147
Updatednan@^2.14.0
Updatednode-pre-gyp@^0.13.0