zoukankan      html  css  js  c++  java
  • 【FishFX】花式撩骚,打造TypeScript易用框架。

    · 栗子入手

    假设有以下foo数组,数组中每个对象都拥有id,name两个属性,现在需要查找id > 0的对象数量。

    const foo: Array<{ id: number, name: string }> = [{
      id: 1,
      name: "cn.troy"
    }, {
      id: 2,
      name: "鱼摆摆"
    }];

    使用for?

    let count: number = 0;
    for (let i = 0; i < foo.length; i++) {
      if (foo[i].id > 0) {
        count++;
      }
    }

    使用forEach?

    let count: number = 0;
    foo.forEach((item)=>{
      if(item.id > 0){
        count++;
      }
    });

    使用filter?

    const count: number = foo.filter(k => k.id > 0).length;

    使用FishFX!!!

    const count: number = foo.f_count(k => k.id > 0);

    又比如我要查找一个数组中,某一个范围的所有对象。

    const arr: Array<any> = foo.f_where(k => k.id > 5 && k.id < 10);

    或者对数据进行验证,看是否所有对象都满足条件等等。

    const isAll: boolean = foo.f_all(k => k.id !== 0);

    看到这里,有同学肯定会问,你这些方法在ES6中都已经实现了啊,比如 array.filter、array.find等等。这框架的意义又是什么呢?

    因为我们的核心理念!!!同时FishFX不仅仅只是array扩展而已,后续也将不断提供更多、更优质的算法封装。

    · Fish Framework(简称:FishFX,中文名:鱼摆摆)

    FishFX 框架是采用 TypeScript(version:3.8.3)现有体系标准,对平时编码时的一些常用功能进行封装,主要思想参考 CoreFX 进行构建。

    我们的核心理念是:“致力于让 TypeScript 拥有如同编写 C# 般的丝滑。”

    · FishFX核心模块

    1. system(v1.0.2):基础功能,如“扩展”、“异常”等实现。
    2. collections(v1.0.2):对“List<T>”、“Dictionary<TKey, TValue>”等功能实现
    3. threading(v1.0.2):对线程相关操作的实现。
    4. docs(实现中):FishFX文档实现,采用VuePress构建。
    5. text(计划中):对文本操作的实现。
    6. reflection(计划中):反射相关实现。
    7. 更多系列模块计划中。

    现在的FishFX还处于襁褓中的婴儿,还请各位大神温柔对待。后期将不定期对FishFX中所有功能进行逐一介绍。

    github:https://github.com/cn-troy/fishfx

    npm:https://www.npmjs.com/package/fishfx

    联系作者:

    抖音(计划中):                                                                 微信:

             

  • 相关阅读:
    基于脚本的nodemanager管理器
    SSH 等效性问题 总提示输入密码问题
    增量检查点【概念】
    【ORA错误大全】 ORA-19527
    DataGuard 配置须知
    rhel5.4+oracle 10g rac
    microg,google新推的一个计划
    [转]Android ListView 与 RecyclerView 对比浅析—缓存机制
    android studio的Beta, Canary, Dev, Stable四种Channel版本介绍、分析与选择
    android studio增量更新
  • 原文地址:https://www.cnblogs.com/Troy-Lv5/p/12765257.html
Copyright © 2011-2022 走看看