mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-31 07:23:06 +08:00
- Preserve lexical captures, callback identity, receiver effects, and default arguments in native bound arrows. - Keep bound function name and length available through JavaScript aliases and checked storage.
8 lines
410 B
TypeScript
8 lines
410 B
TypeScript
// Preset arguments, rest arrows, non-inline arrows and ordinary functions
|
|
// retain their explicit Function.prototype.bind refusal.
|
|
const preset = ((value: number) => value).bind(null, 1);
|
|
const rest = ((...values: number[]) => values.length).bind(null);
|
|
const arrow = (value: number) => value + 1;
|
|
const alias = arrow.bind(null);
|
|
const ordinary = (function (value: number) { return value + 2; }).bind(null);
|