![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Continuation passing style for javascript.
Spoon is a javascript transpiler, it's designed to compile javascript to... javascript.
Lets take following code sample:
var x = 1;
var y = hardMath(x) * 2;
console.log(y);
Suppose you would like to do hardMath
on some remote machine (or in thread),
this will surely require you to make this call asynchronous - i.e. pass a
continuation as a callback for hardMath
function.
Calling spoon(code, ['hardMath'])
will find all occurences of hardMath
and
replace them with following thing:
function __$fn1(__$r) {
y = __$r * 2;
console.log(y);
return __$callback.call(this);
};
var y;
var x;
x = 1;
return hardMath(x, __$fn1);
As you can see __$callback
function should be available in a context.
Spoon isn't just doing stupid tricks with your code, it compiles javascript to well-known form (used by almost every compiler, including v8) HIR (High-Level intermediate representation).
You can do it yourself by calling:
var cfg = spoon.construct(esprima.parse('x = y + 1 * 2'));
console.log(cfg.toString());
Will produce:
--- CFG ---
[block 0]
# predecessors:
# parent: null
# frontier:
# cfrontier:
i0 = var y
i1 = get x
i2 = literal 1
i3 = literal 2
i4 = binop *, i2, i3
i5 = binop +, i1, i4
i6 = set =, y, i5
# successors:
# children:
You can manipulate blocks, change order of instruction, do some optimizations, and, after that, compile CFG back to JS:
spoon.render(cfg);
// Transpile code
spoon(code, [ functions ], {
declaration: 'enable spoon', // spoon will touch only code with
// "enable spoon"; declaration
uglify: {}, // uglifyjs options (used for code generation)
esprima: {} // esprima options (used for parsing)
})
// Construct CFG
var cfg = spoon.construct(EsprimaAST);
// Render CFG
spoon.render(cfg);
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2012.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Continuation passing style for javascript.
The npm package spoon receives a total of 554 weekly downloads. As such, spoon popularity was classified as not popular.
We found that spoon demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.