Upakovka v Electron.JS no po staroy sborke cherez .cjs
This commit is contained in:
4
node_modules/universalify/README.md
generated
vendored
4
node_modules/universalify/README.md
generated
vendored
@@ -1,6 +1,6 @@
|
||||
# universalify
|
||||
|
||||

|
||||
[](https://travis-ci.org/RyanZim/universalify)
|
||||

|
||||

|
||||

|
||||
@@ -21,7 +21,7 @@ npm install universalify
|
||||
|
||||
Takes a callback-based function to universalify, and returns the universalified function.
|
||||
|
||||
Function must take a callback as the last parameter that will be called with the signature `(error, result)`. `universalify` does not support calling the callback with three or more arguments, and does not ensure that the callback is only called once.
|
||||
Function must take a callback as the last parameter that will be called with the signature `(error, result)`. `universalify` does not support calling the callback with more than three arguments, and does not ensure that the callback is only called once.
|
||||
|
||||
```js
|
||||
function callbackFn (n, cb) {
|
||||
|
||||
23
node_modules/universalify/index.js
generated
vendored
23
node_modules/universalify/index.js
generated
vendored
@@ -1,24 +1,25 @@
|
||||
'use strict'
|
||||
|
||||
exports.fromCallback = function (fn) {
|
||||
return Object.defineProperty(function (...args) {
|
||||
if (typeof args[args.length - 1] === 'function') fn.apply(this, args)
|
||||
return Object.defineProperty(function () {
|
||||
if (typeof arguments[arguments.length - 1] === 'function') fn.apply(this, arguments)
|
||||
else {
|
||||
return new Promise((resolve, reject) => {
|
||||
args.push((err, res) => (err != null) ? reject(err) : resolve(res))
|
||||
fn.apply(this, args)
|
||||
arguments[arguments.length] = (err, res) => {
|
||||
if (err) return reject(err)
|
||||
resolve(res)
|
||||
}
|
||||
arguments.length++
|
||||
fn.apply(this, arguments)
|
||||
})
|
||||
}
|
||||
}, 'name', { value: fn.name })
|
||||
}
|
||||
|
||||
exports.fromPromise = function (fn) {
|
||||
return Object.defineProperty(function (...args) {
|
||||
const cb = args[args.length - 1]
|
||||
if (typeof cb !== 'function') return fn.apply(this, args)
|
||||
else {
|
||||
args.pop()
|
||||
fn.apply(this, args).then(r => cb(null, r), cb)
|
||||
}
|
||||
return Object.defineProperty(function () {
|
||||
const cb = arguments[arguments.length - 1]
|
||||
if (typeof cb !== 'function') return fn.apply(this, arguments)
|
||||
else fn.apply(this, arguments).then(r => cb(null, r), cb)
|
||||
}, 'name', { value: fn.name })
|
||||
}
|
||||
|
||||
12
node_modules/universalify/package.json
generated
vendored
12
node_modules/universalify/package.json
generated
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "universalify",
|
||||
"version": "2.0.1",
|
||||
"version": "0.1.2",
|
||||
"description": "Make a callback- or promise-based function support both promises and callbacks.",
|
||||
"keywords": [
|
||||
"callback",
|
||||
@@ -19,16 +19,16 @@
|
||||
"url": "git+https://github.com/RyanZim/universalify.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && nyc --reporter text --reporter lcovonly tape test/*.js | colortape"
|
||||
"test": "standard && nyc tape test/*.js | colortape"
|
||||
},
|
||||
"devDependencies": {
|
||||
"colortape": "^0.1.2",
|
||||
"coveralls": "^3.0.1",
|
||||
"nyc": "^15.0.0",
|
||||
"standard": "^14.3.1",
|
||||
"tape": "^5.0.1"
|
||||
"nyc": "^10.2.0",
|
||||
"standard": "^10.0.1",
|
||||
"tape": "^4.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
"node": ">= 4.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user