@react-dnd/asap
Advanced tools
Comparing version 3.0.0 to 4.0.0
{ | ||
"name": "@react-dnd/asap", | ||
"version": "3.0.0", | ||
"version": "4.0.0", | ||
"description": "High-priority task queue for Node.js and browsers", | ||
@@ -15,13 +15,18 @@ "keywords": [ | ||
}, | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/asap.esm.js", | ||
"main": "dist/cjs/node/index.js", | ||
"module": "dist/esm/browser/index.js", | ||
"types": "lib/node/index.d.ts", | ||
"react-native": { | ||
"domain": false | ||
}, | ||
"browser": { | ||
"./asap": "./dist/esm/browser/asap.js", | ||
"./asap.js": "./dist/esm/browser/asap.js", | ||
"./raw": "./dist/esm/browser/raw.js", | ||
"./raw.js": "./dist/esm/browser/raw.js" | ||
}, | ||
"scripts": { | ||
"start": "tsdx watch", | ||
"build": "tsdx build", | ||
"test": "tsdx test", | ||
"lint": "tsdx lint" | ||
"build": "./scripts/build.sh", | ||
"lint": "tsdx lint", | ||
"test": "tsdx test" | ||
}, | ||
@@ -42,2 +47,6 @@ "peerDependencies": {}, | ||
"@types/jest": "^24.0.23", | ||
"@babel/core": "^7.7.5", | ||
"@babel/cli": "^7.7.5", | ||
"@babel/preset-env": "^7.7.5", | ||
"babel-preset-env": "^1.7.0", | ||
"husky": "^3.1.0", | ||
@@ -44,0 +53,0 @@ "tsdx": "^0.11.0", |
@@ -1,63 +0,2 @@ | ||
import { Task, Domain } from './types'; | ||
import { rawAsap } from './raw'; | ||
const freeTasks: Task[] = []; | ||
/** | ||
* Calls a task as soon as possible after returning, in its own event, with | ||
* priority over IO events. An exception thrown in a task can be handled by | ||
* `process.on("uncaughtException") or `domain.on("error")`, but will otherwise | ||
* crash the process. If the error is handled, all subsequent tasks will | ||
* resume. | ||
* | ||
* @param {{call}} task A callable object, typically a function that takes no | ||
* arguments. | ||
*/ | ||
export function asap(task: Task) { | ||
var rawTask; | ||
if (freeTasks.length) { | ||
rawTask = freeTasks.pop(); | ||
} else { | ||
rawTask = new RawTask(); | ||
} | ||
rawTask.task = task; | ||
rawTask.domain = process.domain; | ||
rawAsap(rawTask); | ||
} | ||
class RawTask { | ||
public task: Task; | ||
public domain: Domain; | ||
public call() { | ||
if (this.domain) { | ||
this.domain.enter(); | ||
} | ||
var threw = true; | ||
try { | ||
this.task.call(); | ||
threw = false; | ||
// If the task throws an exception (presumably) Node.js restores the | ||
// domain stack for the next event. | ||
if (this.domain) { | ||
this.domain.exit(); | ||
} | ||
} finally { | ||
// We use try/finally and a threw flag to avoid messing up stack traces | ||
// when we catch and release errors. | ||
if (threw) { | ||
// In Node.js, uncaught exceptions are considered fatal errors. | ||
// Re-throw them to interrupt flushing! | ||
// Ensure that flushing continues if an uncaught exception is | ||
// suppressed listening process.on("uncaughtException") or | ||
// domain.on("error"). | ||
rawAsap.requestFlush(); | ||
} | ||
// If the task threw an error, we do not want to exit the domain here. | ||
// Exiting the domain would prevent the domain from catching the error. | ||
this.task = null; | ||
this.domain = null; | ||
freeTasks.push(this); | ||
} | ||
} | ||
} | ||
export { asap as nodeAsap } from './node/asap'; | ||
export { asap as browserAsap } from './node/asap'; |
{ | ||
"include": ["src", "types", "test"], | ||
"compilerOptions": { | ||
@@ -10,3 +9,3 @@ "target": "es5", | ||
"sourceMap": true, | ||
"rootDir": "./", | ||
"rootDir": "./src", | ||
"strict": true, | ||
@@ -24,3 +23,3 @@ "noImplicitAny": true, | ||
"moduleResolution": "node", | ||
"baseUrl": "./", | ||
"baseUrl": "./src", | ||
"paths": { | ||
@@ -30,4 +29,6 @@ "*": ["src/*", "node_modules/*"] | ||
"jsx": "react", | ||
"esModuleInterop": true | ||
} | ||
"esModuleInterop": true, | ||
"outDir": "lib" | ||
}, | ||
"files": ["src/browser/index.ts", "src/node/index.ts"], | ||
} |
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
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1742
1
0
104373
9
51
1