Merge pull request #1518 from babel/es7.functionBind
Add experimental support for ES7 function bind.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
::foo.bar.foo;
|
||||
::foo.bar["foo"];
|
||||
|
||||
ctx::foo.bar.foo;
|
||||
ctx::foo.bar["foo"];
|
||||
@@ -0,0 +1,5 @@
|
||||
::foo.bar.foo;
|
||||
::foo.bar["foo"];
|
||||
|
||||
ctx::foo.bar.foo;
|
||||
ctx::foo.bar["foo"];
|
||||
@@ -0,0 +1,3 @@
|
||||
var f = ctx::ns.obj.func;
|
||||
var g = ::ns.obj.func;
|
||||
var h = new X::y;
|
||||
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
var _context;
|
||||
|
||||
var f = (_context = ctx, ns.obj.func).bind(_context);
|
||||
var g = (_context = ns.obj).func.bind(_context);
|
||||
var h = (_context = new X(), y).bind(_context);
|
||||
@@ -0,0 +1,4 @@
|
||||
ctx::ns.obj.func();
|
||||
::ns.obj.func();
|
||||
|
||||
ns.obj2::ns.obj1.func();
|
||||
@@ -0,0 +1,8 @@
|
||||
"use strict";
|
||||
|
||||
var _context;
|
||||
|
||||
(_context = ctx, ns.obj.func).call(_context);
|
||||
(_context = ns.obj).func.call(_context);
|
||||
|
||||
(_context = ns.obj2, ns.obj1.func).call(_context);
|
||||
@@ -0,0 +1,6 @@
|
||||
import { map, takeWhile, forEach } from "iterlib";
|
||||
|
||||
getPlayers()
|
||||
::map(x => x.character())
|
||||
::takeWhile(x => x.strength > 100)
|
||||
::forEach(x => console.log(x));
|
||||
@@ -0,0 +1,27 @@
|
||||
var operations = [];
|
||||
|
||||
var lib = {};
|
||||
|
||||
for (let key of ['f', 'g', 'h']) {
|
||||
let func = () => operations.push(`lib.${key}()`);
|
||||
Object.defineProperty(lib, key, {
|
||||
get() {
|
||||
operations.push(`get lib.${key}`);
|
||||
return func;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
({prop:'value'})
|
||||
::lib.f()
|
||||
::lib.g()
|
||||
::lib.h();
|
||||
|
||||
assert.deepEqual(operations, [
|
||||
'get lib.f',
|
||||
'lib.f()',
|
||||
'get lib.g',
|
||||
'lib.g()',
|
||||
'get lib.h',
|
||||
'lib.h()'
|
||||
]);
|
||||
@@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
|
||||
var _context;
|
||||
|
||||
var _iterlib = require("iterlib");
|
||||
|
||||
(_context = (_context = (_context = getPlayers(), _iterlib.map).call(_context, function (x) {
|
||||
return x.character();
|
||||
}), _iterlib.takeWhile).call(_context, function (x) {
|
||||
return x.strength > 100;
|
||||
}), _iterlib.forEach).call(_context, function (x) {
|
||||
return console.log(x);
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"optional": "es7.functionBind"
|
||||
}
|
||||
Reference in New Issue
Block a user