Comparing version 0.2.0 to 1.0.0
@@ -1,4 +0,14 @@ | ||
## 0.1.0 (17 October 2017) | ||
## 12 May 2018 | ||
### 1.0.0 | ||
- [test] use [`noddy`](https://artdeco.bz/noddy) to detect `Node.js` version | ||
- [build] switch to new build routine and test w/ `zoroaster --babel` | ||
- [adc] move to [Art Deco Code](https://artdeco.bz) | ||
## 17 October 2017 | ||
### 0.1.0 | ||
- Create `erotic`: a package created with `mnp` | ||
- [repo]: `test`, `src` |
var _require = require('./lib'), | ||
getCallerFromArguments = _require.getCallerFromArguments, | ||
getCalleeStackLine = _require.getCalleeStackLine, | ||
getStackHeading = _require.getStackHeading; | ||
getCallerFromArguments = _require.getCallerFromArguments, | ||
getCalleeStackLine = _require.getCalleeStackLine, | ||
getStackHeading = _require.getStackHeading | ||
var cleanStack = require('clean-stack'); | ||
var cleanStack = require('clean-stack') | ||
@@ -16,3 +16,3 @@ /** | ||
function makeCallback(entryCaller, entryStack) { | ||
/** | ||
/** | ||
* This callback should be called when an asynchronous error occured. | ||
@@ -24,25 +24,25 @@ * @param {(string|Error)} messageOrError A message string or an Error object at | ||
*/ | ||
function eroticCallback(messageOrError) { | ||
var caller = getCallerFromArguments(arguments); | ||
function eroticCallback(messageOrError) { | ||
var caller = getCallerFromArguments(arguments) | ||
var _ref = new Error(), | ||
errorStack = _ref.stack; | ||
var _ref = new Error(), | ||
errorStack = _ref.stack | ||
var calleeStackLine = getCalleeStackLine(errorStack); | ||
var isError = messageOrError instanceof Error; | ||
var message = isError ? messageOrError.message : messageOrError; | ||
var calleeStackLine = getCalleeStackLine(errorStack) | ||
var isError = messageOrError instanceof Error | ||
var message = isError ? messageOrError.message : messageOrError | ||
var stackHeading = getStackHeading(message); | ||
var entryHasCallee = entryCaller === caller; | ||
var stackMessage = [stackHeading].concat(entryHasCallee ? entryStack : [calleeStackLine, entryStack]).join('\n'); | ||
var stack = cleanStack(stackMessage); | ||
var properties = { message, stack }; | ||
return Object.assign(new Error(), isError ? Object.assign({}, messageOrError, properties) : properties); | ||
} | ||
var stackHeading = getStackHeading(message) | ||
var entryHasCallee = entryCaller === caller | ||
var stackMessage = [stackHeading].concat(entryHasCallee ? entryStack : [calleeStackLine, entryStack]).join('\n') | ||
var stack = cleanStack(stackMessage) | ||
var properties = { message, stack } | ||
return Object.assign(new Error(), isError ? Object.assign({}, messageOrError, properties) : properties) | ||
} | ||
return eroticCallback; | ||
return eroticCallback | ||
} | ||
module.exports = { | ||
makeCallback | ||
}; | ||
makeCallback, | ||
} |
var _require = require('./lib'), | ||
getEntryStack = _require.getEntryStack, | ||
getCallerFromArguments = _require.getCallerFromArguments; | ||
getEntryStack = _require.getEntryStack, | ||
getCallerFromArguments = _require.getCallerFromArguments | ||
var _require2 = require('./callback'), | ||
makeCallback = _require2.makeCallback; | ||
makeCallback = _require2.makeCallback | ||
@@ -15,9 +15,9 @@ /** | ||
function erotic() { | ||
var error = new Error(); | ||
var caller = getCallerFromArguments(arguments); | ||
var entryStack = getEntryStack(error.stack); | ||
var error = new Error() | ||
var caller = getCallerFromArguments(arguments) | ||
var entryStack = getEntryStack(error.stack) | ||
return makeCallback(caller, entryStack); | ||
return makeCallback(caller, entryStack) | ||
} | ||
module.exports = erotic; | ||
module.exports = erotic |
var getLastItem = function getLastItem(array) { | ||
var item = array[array.length - 1]; | ||
return item; | ||
}; | ||
var item = array[array.length - 1] | ||
return item | ||
} | ||
var getItemsFrom = function getItemsFrom(array, from) { | ||
return array.slice(from); | ||
}; | ||
return array.slice(from) | ||
} | ||
@@ -17,17 +17,17 @@ /** | ||
var getStackSegment = function getStackSegment(stack) { | ||
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var oneLine = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
var from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0 | ||
var oneLine = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false | ||
if (from === 0 && !oneLine) { | ||
return stack; | ||
} | ||
var splitStack = stack.split('\n', oneLine ? from + 1 : Number.Infinity); | ||
if (oneLine) { | ||
var line = getLastItem(splitStack); | ||
return line; | ||
} else { | ||
var items = getItemsFrom(splitStack, from); | ||
return items.join('\n'); | ||
} | ||
}; | ||
if (from === 0 && !oneLine) { | ||
return stack | ||
} | ||
var splitStack = stack.split('\n', oneLine ? from + 1 : Number.Infinity) | ||
if (oneLine) { | ||
var line = getLastItem(splitStack) | ||
return line | ||
} else { | ||
var items = getItemsFrom(splitStack, from) | ||
return items.join('\n') | ||
} | ||
} | ||
@@ -42,5 +42,5 @@ /** | ||
var getEntryStack = function getEntryStack(stack) { | ||
var stackSegment = getStackSegment(stack, 2); | ||
return stackSegment; | ||
}; | ||
var stackSegment = getStackSegment(stack, 2) | ||
return stackSegment | ||
} | ||
@@ -53,9 +53,9 @@ /** | ||
var getCalleeStackLine = function getCalleeStackLine(stack) { | ||
var calleeStackLine = getStackSegment(stack, 2, true); | ||
return calleeStackLine; | ||
}; | ||
var calleeStackLine = getStackSegment(stack, 2, true) | ||
return calleeStackLine | ||
} | ||
var getStackHeading = function getStackHeading(message) { | ||
return `Error: ${message}`; | ||
}; | ||
return `Error: ${message}` | ||
} | ||
@@ -69,13 +69,13 @@ /** | ||
var getCallerFromArguments = function getCallerFromArguments(args) { | ||
var caller = args.callee.caller; | ||
var caller = args.callee.caller | ||
return caller; | ||
}; | ||
return caller | ||
} | ||
module.exports = { | ||
getStackSegment, | ||
getCalleeStackLine, | ||
getEntryStack, | ||
getStackHeading, | ||
getCallerFromArguments | ||
}; | ||
getStackSegment, | ||
getCalleeStackLine, | ||
getEntryStack, | ||
getStackHeading, | ||
getCallerFromArguments, | ||
} |
{ | ||
"name": "erotic", | ||
"version": "0.2.0", | ||
"version": "1.0.0", | ||
"description": "Capture synchronous part of the error stack in asynchronous functions", | ||
"main": "src/index.js", | ||
"main": "build", | ||
"scripts": { | ||
"test": "zoroaster test/spec", | ||
"test": "zoroaster test/spec --babel", | ||
"test-build": "LIB_MAIN=../../build zoroaster test/spec --babel", | ||
"test-es5": "zoroaster es5/test/spec", | ||
@@ -14,11 +15,12 @@ "test-watch": "zoroaster test/spec --watch", | ||
"build-test": "babel test --out-dir es5/test", | ||
"build": "run-s build-src build-test" | ||
"build": "babel src --out-dir build" | ||
}, | ||
"files": [ | ||
"src", | ||
"es5/src" | ||
"build", | ||
"es5/src", | ||
"es5/index.js" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/Sobesednik/erotic.git" | ||
"url": "git://github.com/artdecocode/erotic.git" | ||
}, | ||
@@ -29,14 +31,16 @@ "keywords": [ | ||
], | ||
"author": "Anton <anton@sobesednik.media>", | ||
"author": "Anton <anton@adc.sh>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Sobesednik/erotic/issues" | ||
"url": "https://github.com/artdecocode/erotic/issues" | ||
}, | ||
"homepage": "https://github.com/Sobesednik/erotic#readme", | ||
"homepage": "https://github.com/artdecocode/erotic#readme", | ||
"devDependencies": { | ||
"babel-cli": "6.26.0", | ||
"babel-preset-env": "1.6.1", | ||
"fast-async": "6.3.0", | ||
"npm-run-all": "4.1.2", | ||
"zoroaster": "0.4.6" | ||
"@babel/cli": "7.0.0-beta.46", | ||
"@babel/core": "7.0.0-beta.46", | ||
"@babel/plugin-syntax-object-rest-spread": "7.0.0-beta.46", | ||
"@babel/plugin-transform-modules-commonjs": "7.0.0-beta.46", | ||
"@babel/register": "7.0.0-beta.46", | ||
"noddy": "1.1.1", | ||
"zoroaster": "1.1.0" | ||
}, | ||
@@ -43,0 +47,0 @@ "dependencies": { |
@@ -1,5 +0,9 @@ | ||
<a href="https://npmjs.org/packages/erotic"><img align="right" src="./logo.jpg" width="225" alt="Erotic" /> | ||
<a href="https://artdeco.bz/erotic"><img align="right" src="./logo.jpg" width="225" alt="Erotic" /> | ||
# erotic</a> | ||
``` | ||
yarn add -E erotic | ||
``` | ||
[`erotic`][1] is a Node.js module to capture asynchronous stack traces. | ||
@@ -15,11 +19,2 @@ | ||
## ES5 | ||
The package uses some newer language features. For your convenience, it's been | ||
transpiled to be compatible with Node 4. You can use the following snippet. | ||
```js | ||
const erotic = require('erotic/es5/src/') | ||
``` | ||
## API | ||
@@ -105,6 +100,6 @@ | ||
Error: promise timeout error | ||
at Timeout.setTimeout [as _onTimeout] (/Users/anton/Sobes/erotic/example/erotic.js:30:27) | ||
at exampleWithPromise (/Users/anton/Sobes/erotic/example/erotic.js:27:17) | ||
at __dirname (/Users/anton/Sobes/erotic/example/erotic.js:56:11) | ||
at Object.<anonymous> (/Users/anton/Sobes/erotic/example/erotic.js:57:3) | ||
at Timeout.setTimeout [as _onTimeout] (artdeco/erotic/example/erotic.js:30:27) | ||
at exampleWithPromise (artdeco/erotic/example/erotic.js:27:17) | ||
at __dirname (artdeco/erotic/example/erotic.js:56:11) | ||
at Object.<anonymous> (artdeco/erotic/example/erotic.js:57:3) | ||
``` | ||
@@ -137,2 +132,13 @@ | ||
## ES5 | ||
> THIS SHOULD NOT BE USED. THIS IS BEING REMOVED. USE LATEST NODE. | ||
The package uses some newer language features. For your convenience, it's been | ||
transpiled to be compatible with Node 4. You can use the following snippet. | ||
```js | ||
const erotic = require('erotic/es5') | ||
``` | ||
--- | ||
@@ -143,5 +149,6 @@ | ||
(c) [Sobesednik-Media](https://sobes.io) 2017 | ||
(c) [Art Deco Code][3] 2018 | ||
[1]: https://npmjs.org/packages/erotic | ||
[2]: https://publicdomainreview.org/2015/03/11/sex-and-science-in-robert-thorntons-temple-of-flora/ | ||
[3]: https://artdeco.bz |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
17312
11
0
151
7
228