mirror of
https://github.com/10h30/odin-javascript-exercises.git
synced 2026-07-12 11:16:09 +09:00
Clean up the oopsie. Rebuild the blank exercises.
This commit is contained in:
+10
-5
@@ -1,8 +1,13 @@
|
||||
'use strict';
|
||||
module.exports = function () {
|
||||
var _ = Error.prepareStackTrace;
|
||||
Error.prepareStackTrace = function (_, stack) { return stack };
|
||||
var stack = new Error().stack.slice(1);
|
||||
Error.prepareStackTrace = _;
|
||||
|
||||
const callsites = () => {
|
||||
const _prepareStackTrace = Error.prepareStackTrace;
|
||||
Error.prepareStackTrace = (_, stack) => stack;
|
||||
const stack = new Error().stack.slice(1);
|
||||
Error.prepareStackTrace = _prepareStackTrace;
|
||||
return stack;
|
||||
};
|
||||
|
||||
module.exports = callsites;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = callsites;
|
||||
|
||||
+23
-20
@@ -1,31 +1,31 @@
|
||||
{
|
||||
"_from": "callsites@^0.2.0",
|
||||
"_id": "callsites@0.2.0",
|
||||
"_from": "callsites@^3.0.0",
|
||||
"_id": "callsites@3.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=",
|
||||
"_integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
|
||||
"_location": "/callsites",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "callsites@^0.2.0",
|
||||
"raw": "callsites@^3.0.0",
|
||||
"name": "callsites",
|
||||
"escapedName": "callsites",
|
||||
"rawSpec": "^0.2.0",
|
||||
"rawSpec": "^3.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.2.0"
|
||||
"fetchSpec": "^3.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/caller-path"
|
||||
"/@jest/source-map"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/callsites/-/callsites-0.2.0.tgz",
|
||||
"_shasum": "afab96262910a7f33c19a5775825c69f34e350ca",
|
||||
"_spec": "callsites@^0.2.0",
|
||||
"_where": "/Users/cloyd/coderrr/odin/javascript-exercises/node_modules/caller-path",
|
||||
"_resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz",
|
||||
"_shasum": "b3630abd8943432f54b3f0519238e33cd7df2f73",
|
||||
"_spec": "callsites@^3.0.0",
|
||||
"_where": "/home/michael/projects/javascript-exercises/node_modules/@jest/source-map",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "http://sindresorhus.com"
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/callsites/issues"
|
||||
@@ -34,20 +34,23 @@
|
||||
"deprecated": false,
|
||||
"description": "Get callsites from the V8 stack trace API",
|
||||
"devDependencies": {
|
||||
"mocha": "*"
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
"node": ">=6"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/sindresorhus/callsites#readme",
|
||||
"keywords": [
|
||||
"callsites",
|
||||
"callsite",
|
||||
"v8",
|
||||
"stacktrace",
|
||||
"v8",
|
||||
"callsite",
|
||||
"callsites",
|
||||
"stack",
|
||||
"trace",
|
||||
"function",
|
||||
@@ -62,7 +65,7 @@
|
||||
"url": "git+https://github.com/sindresorhus/callsites.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "0.2.0"
|
||||
"version": "3.1.0"
|
||||
}
|
||||
|
||||
+17
-16
@@ -1,47 +1,48 @@
|
||||
# callsites [](https://travis-ci.org/sindresorhus/callsites)
|
||||
|
||||
> Get callsites from the [V8 stack trace API](https://code.google.com/p/v8/wiki/JavaScriptStackTraceApi)
|
||||
> Get callsites from the [V8 stack trace API](https://v8.dev/docs/stack-trace-api)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install --save callsites
|
||||
```
|
||||
$ npm install callsites
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var callsites = require('callsites');
|
||||
const callsites = require('callsites');
|
||||
|
||||
function unicorn() {
|
||||
console.log(callsites()[0].getFileName());
|
||||
//=> /Users/sindresorhus/dev/callsites/test.js
|
||||
//=> '/Users/sindresorhus/dev/callsites/test.js'
|
||||
}
|
||||
|
||||
unicorn();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
Returns an array of callsite objects with the following methods:
|
||||
|
||||
- `getThis`: returns the value of this
|
||||
- `getTypeName`: returns the type of this as a string. This is the name of the function stored in the constructor field of this, if available, otherwise the object's [[Class]] internal property.
|
||||
- `getFunction`: returns the current function
|
||||
- `getFunctionName`: returns the name of the current function, typically its name property. If a name property is not available an attempt will be made to try to infer a name from the function's context.
|
||||
- `getMethodName`: returns the name of the property of this or one of its prototypes that holds the current function
|
||||
- `getFileName`: if this function was defined in a script returns the name of the script
|
||||
- `getLineNumber`: if this function was defined in a script returns the current line number
|
||||
- `getThis`: returns the value of `this`.
|
||||
- `getTypeName`: returns the type of `this` as a string. This is the name of the function stored in the constructor field of `this`, if available, otherwise the object's `[[Class]]` internal property.
|
||||
- `getFunction`: returns the current function.
|
||||
- `getFunctionName`: returns the name of the current function, typically its `name` property. If a name property is not available an attempt will be made to try to infer a name from the function's context.
|
||||
- `getMethodName`: returns the name of the property of `this` or one of its prototypes that holds the current function.
|
||||
- `getFileName`: if this function was defined in a script returns the name of the script.
|
||||
- `getLineNumber`: if this function was defined in a script returns the current line number.
|
||||
- `getColumnNumber`: if this function was defined in a script returns the current column number
|
||||
- `getEvalOrigin`: if this function was created using a call to eval returns a CallSite object representing the location where eval was called
|
||||
- `isToplevel`: is this a toplevel invocation, that is, is this the global object?
|
||||
- `isEval`: does this call take place in code defined by a call to eval?
|
||||
- `getEvalOrigin`: if this function was created using a call to `eval` returns a string representing the location where `eval` was called.
|
||||
- `isToplevel`: is this a top-level invocation, that is, is this the global object?
|
||||
- `isEval`: does this call take place in code defined by a call to `eval`?
|
||||
- `isNative`: is this call in native V8 code?
|
||||
- `isConstructor`: is this a constructor call?
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](http://sindresorhus.com)
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
||||
|
||||
Reference in New Issue
Block a user