Skip to content

Instantly share code, notes, and snippets.

@tyru
Forked from davidosomething/function-type-test.js
Created February 12, 2016 15:36
Show Gist options
  • Save tyru/18b30b3874522fc16595 to your computer and use it in GitHub Desktop.
Save tyru/18b30b3874522fc16595 to your computer and use it in GitHub Desktop.
Various function styles for testing
/*eslint-env es6*/
// ES6 generator function
var anonymousGeneratorFunctionExpression = function* (arg1, arg2) {
};
var namedGeneratorFunctionExpression = function* namedGenerator(arg1, arg2) {
};
var anonymousFunctionExpression = function (arg1, arg2) {
};
var namedFunctionExpression = function namedExpression(el, $jq) {
}
function namedFunctionDeclaration(_a2, err) {
}
function* namedGeneratorFunc(data) {
}
const namespace = {
toString() { // ES6 style dec
},
};
namespace.x0 = function (e) {
}; // anonymous method
namespace.x1 = (e) => {
}; // anonymous arrow method
namespace.x2 = function* (e) {
}; // anonymous method generator
namespace.x3 = function testing(e) {
}; // named method
namespace.x4 = function* testgen(description) {
}; // named method generator
namespace.x5 = () => 'hi'; // arrow function with auto returning body
// arrow function, spread, with function body
const xxx = (...args) => {
return 'bye';
}
// arrow function, spread, with auto returning body
const yyy = (...args) => 'hello';
// arrow function, spread, with auto returning object
const zzz = (...args) => ({ key: 'value' });
// arrow function with no arg parens
const aaa = v => 'vvv';
const bbb = v => ({ item: 'vvv' });
const ccc = v => {
return v || false;
};
class ExampleClass {
somefunc(somearg) {
}
get getterfunc() {
}
set setter(value) {
}
static staticfunc(staticarg) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment