代码拉取完成,页面将自动刷新
The wonderful lib for function in
Javascript
@func-js/core
: The core js, includes the basic functions and usages.@func-js/async
: The enhancement for core js, get to support multi features for async methods.@func-js/utils
: The utils for all packages.Method Hooker - Live Demo
If you want to do something before or after the method called, you can using before
or after
method from @func-js/core
module.
const {give} = require('@func-js/core');
/**
* Auto parameters by using before
*/
function genInfo(id) {
return {
id: id,
name: 'Info #' + id
}
}
var autoGenInfo = give(genInfo)
.before(function (params) {
var args = params.args;
if (!args[0]) {
args[0] = '88888';
}
});
console.log(autoGenInfo()); // > { id: '88888', name: 'Info #88888', autoGen: true }
console.log(autoGenInfo('4123')); // > { id: '4123', name: 'Info #4123' }
/**
* Using after to sign now timestamp for last return value
*/
var signTimeInfo = autoGenInfo.after(
function (params) {
var lastValue = params.lastValue;
lastValue.singTime = Date.now();
return lastValue;
}
);
console.log(signTimeInfo()); // > { id: '88888', name: 'Info #88888', singTime: 1609772675561 }
@func-js/core
: Documentation
@func-js/async
: Documentation
@func-js/utils
: Documentation
yarn install
to begin your developments.此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。