
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
fancierscript
Advanced tools
Fancier FancyScript
FancierScript aims to make developing in FancyScript easier and more powerful while remaining "just FancyScript". For a completely different approach with diverse syntax rules, and in the latter case, a powerful standard library, look toward CoffeeScript or ClojureScript. FancierScript compiles to plain ES5 JavaScript. Thanks @btmills for the name.
npm install -g fancierscript installs the FancierScript binary fancier so it can be used globally.
fancier input.fs compiles the FancierScript source file input.fs to plain JavaScript in input.js.
-b, --bare Compile without a top-level function wrapper.-o, --out [DIR] Write all compiled JavaScript files into the specified directory.-r, --repl Start an interactive FancierScript REPL. Interrupts all other options.-w, --watch Watch specified files for changes.FancierScript follows strict-mode JavaScript conventions. Unless the --bare option is passed, the compiled code is wrapped in an IIFE (Immediately-Invoked Function Expression) with "use strict"; inside. For the sake of clarity, other examples will not include the function wrapper and strict mode declaration.
var a = 42;
(function () {
"use strict";
var a = 42;
}).call(this);
Arrow functions in Harmony are a more concise syntax for function expressions, consisting of a parameter list and an automatically-returned expression or a statement block.
[1, 2, 3, 4].map(x => x * x);
[1, 2, 3, 4].map(function (x) {
return x * x;
});
Use default arguments to provide a default value within the function's parameter list for any optional arguments.
function foo(a, b = 42, c, d = bar(), e) { }
function foo(a, b, c, d, e) {
if (typeof b === 'undefined') { b = 42; }
if (typeof d === 'undefined') { d = bar(); }
}
From the MDN page, rest parameters represent "an indefinite number of arguments as an array." A function declaration or function expression may have a rest parameter as its last argument which will absorb all the rest of the arguments when the function is called.
fn isEven (...x) {
x.every(fn (x) { x % 2 === 0 });
}
function isEven() {
var x = Array.prototype.slice.call(arguments, 0);
return x.every(function (x) {
return x % 2 === 0;
});
}
isEven(2, 4, 6); // true
From the MDN page, the spread operator expands an expression into multiple arguments to a function or multiple elements in array literals. Currently only the former case is supported, but the latter is in progress.
var arr = ['b', 'c', 'd'];
console.log('a', ...arr, 'e');
var arr = ['b', 'c', 'd'];
console.log.apply(console.log, [].concat(['a'], arr, ['e'])); // a b c d e
Note that support for the spread operator in a call to Function.prototype.apply is neither available nor planned. A compelling use case would be needed.
Array destructuring can occur in variable declarations, assignment expressions, or function parameters.
var [a, b] = [11, 42];
console.log([a, b] = [b, a]); // [42, 11]
function show([, second]) {
console.log(second);
}
show([a, b]); // 11
var $tmp = [11, 42], a = $tmp[0], b = $tmp[1];
console.log(function ($tmp) {
a = $tmp[0];
b = $tmp[1];
return $tmp;
}([b, a]));
function show($tmp) {
var second = $tmp[1];
return console.log(second);
}
show([a, b]);
Like array destructuring, object destructuring is syntactic sugar for more easily creating objects or retrieving values from them. This can occur in variable declarations, function parameter lists, or as a shortcut in object expressions.
var { name, age: a } = getPerson(); // Declare variables "name" and "a"
var obj = { name, age: a }; // Shortcut to initialize obj.name to variable "name"
function ({ name, age: b}, cb) { }
({ name, age: a }) = getAnotherPerson();
var $tmp = getPerson(), name = $tmp['name'], a = $tmp['age'];
var obj = { name: name, age: a };
function ($tmp2, cb) {
var name = $tmp2['name'], b = $tmp2['age'];
}
(function ($tmp3) {
name = $tmp3['name'];
a = $tmp3['age'];
return $tmp3;
})(getAnotherPerson());
If the last statement of a function is an expression contained in an ExpressionStatement, it is automatically returned.
fn isEven (x) { x % 2 === 0 }
function isEven(x) {
return x % 2 === 0;
}
fn keywordfn is an alias to the function keyword and is interchangeable.
fn hello () {
conole.log('Hello, world!');
}
function hello () {
console.log('Hello, world!');
}
var isEven = (x, ...r) => x % 2 === 0 && (r.length ? isEven(...r) : true)
var isEven = function (x) {
var r = Array.prototype.slice.call(arguments, 1);
return x % 2 === 0 && (r.length ? isEven.apply(isEven, [].concat(r)) : true);
}
isEven(2, 4, 6, 7); // false
isEven(2, 4, 6, 8); // true
Licensed under the BSD 3-Clause License, the full text of which can be read in LICENSE.
FAQs
Fancier JavaScript
The npm package fancierscript receives a total of 2 weekly downloads. As such, fancierscript popularity was classified as not popular.
We found that fancierscript 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.