1 Star 0 Fork 1

苍石 / func-js

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

@func-js

The wonderful lib for function in Javascript

Packages

  • @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.

Demos

  1. 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 }

Documents

Need Contributors

  1. Fork the git repository, and download to local.
  2. Run yarn install to begin your developments.

Git Repository

Comments ( 0 )

Sign in for post a comment

About

javascript framework for making function powerful spread retract
Cancel

Releases

No release

func-js

Contributors

All

Activities

load more
can not load any more
JavaScript
1
https://gitee.com/HGJing/func-js.git
git@gitee.com:HGJing/func-js.git
HGJing
func-js
func-js
master

Search

102255 3a0e046c 1850385 102255 7aaa926c 1850385