Giter VIP home page Giter VIP logo

cnc-tskit's People

Contributors

dependabot[bot] avatar mzimandl avatar tomachalek avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cnc-tskit's Issues

new namespace Client, new function Client.isMobileTouchDevice

the file should be arc/client.ts. The code should be (taken from WaG):

export namespace Client {
  export function isTouchDevice():boolean {
    return window.matchMedia('screen and (max-width: 480px)').matches
                && (('ontouchstart' in window) || window['DocumentTouch'] && document instanceof 
        DocumentTouch)
  }
}

Because of the function's nature there will be no tests.

new function List.unique

This should remove all the duplicities based on provided "key" function.

e.g.: List.unique( v => v.firstname + v.lastname, items), List.unique(v => v, [1, 2, 3, 3, 2, 1])

New namespace Time, new function secs2hms

Sample implementation

    const h = Math.floor(v / 3600);
    const m = Math.floor((v % 3600) / 60);
    const s = v % 60;
    const lz = (v:number) => v < 10 ? `0${v.toFixed()}` : v.toFixed();
    return `${lz(h)}:${lz(m)}:${lz(s)}`;

new namespace URL and function join

// signature:
URL.join(...items:Array<string>):string

The function should make sure all the "joint" points contain only a single slash:

console.log(URL.join('/foo/', '/bar/'))
// produces: /foo/bar/

(the leading and trailing slashes should be preserved)

add List.head, List.tail functions (+ tests)

Signatures:

export function head<T>(data:Array<T>):T;
export function head<T>():(data:Array<T>)=>T;
export function head<T>(data?:Array<T>):any {
  // implementation...
}

Head on an empty array should throw an error.

export function tail<T>(data:Array<T>):Array<T>;
export function tail<T>():(data:Array<T>)=>Array<T>;
export function tail<T>(data?:Array<T>):any {
  // implementation...
}

Tail on an empty array should return an empty array.

The functions should not affect the original array.

const v = List.head([0, 1, 2, 3, 4]);
// v is 0

const t = List.tail([0, 1, 2, 3, 4]);
// t is [1, 2, 3, 4]

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.