czcorpus / cnc-tskit Goto Github PK
View Code? Open in Web Editor NEWBunch of reusable TypeScript functions
License: Apache License 2.0
Bunch of reusable TypeScript functions
License: Apache License 2.0
which removes item at position idx. In case the list has no such position it should throw an error.
see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values
We should do the following:
Value
matching the values from the link abovekey
first then keyCode
and handle the different values).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.
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])
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)}`;
// 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)
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]
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.