Giter Site home page Giter Site logo

tool's Introduction

what I wanted I created it

Array

  1. midSort
// 重排数组 将数组的元素从中间开始重排
midSort([1,2,3,4,5]) => [3, 2, 4, 1, 5]

Sort

  1. topA
// 重排数组 将数组的元素按照某种前后条件,向上对齐
// 矩阵重排的基本函数
  const eg = [
    {bool: true, value: 1},
    {bool: false, value: 2},
    {bool: true, value: 3},
    {bool: false, value: 4},
  ]
  let res = [];
  let juede = t => t.bool;
  let act = t => res.push(t);
  topA(eg, juede, act)
  => res = [
    {bool: true, value: 1},
    {bool: true, value: 3},
    {bool: false, value: 2},
    {bool: false, value: 4},
  ]
  1. bottomA
// 重排数组 将数组的元素按照某种前后条件,向下对齐
// 与topA类似, 具体查看测试用例
  1. midA
// 重排数组 将数组的元素按照false包围true且分布尽量均匀,进行分布
// 与topA类似, 具体查看测试用例

timer

  1. intervalTime
// 设定一个函数每隔一定时间(setInterval)执行一定次数,执行完毕后调用传入的回调,可以中途取消
intervalTime(() => 1, 100, 100, () => console.log("100!")) // 100 * 100 ms后 => 100

ExeRun

  1. compareExeRun
// 比较多种程序在一定次数下的执行效率
// eg
let exes = [
  () => new Date().getTime(),
  () => +new Date(),
  () => 2 * 262144,
  () => 2 << 50
]

console.log(compareExeRun(exes, 1e7));

tool's People

Watchers

James Cloos avatar  avatar wudu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.