Skip to content

Eczbek/lingcod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lingcod

JavaScript utility library

Installation

npm i lingcod

Usage/Examples

import { mergeSort } from 'lingcod/algorithm';

console.log(mergeSort([3,4,9,1,2,0,2])); // [0,1,2,2,3,4,9]
import { Point, Segment } from 'lingcod/geometry';

const a = new Segment(new Point(0, 0), new Point(10, 10));
const b = new Segment(new Point(10, 0), new Point(0, 10));

console.log(Segment.intersections(a, b)); // [Point(5, 5)]
import { wrap } from 'lingcod/math';

console.log(wrap(7, 5, -5)); // -2
import { randHexColor } from 'lingcod/random';

console.log(randHexColor('#ff11ff', '#0000ff')); // '#4a01ff'
import { wrapMatrix } from 'lingcod/matrix';

console.log(wrapMatrix([1,2,3,4], [2,2])); // [[1,2],[3,4]]
import { createTimeFormat } from 'lingcod/time';

const timeFormat = createTimeFormat('%Y-%M-%D %H:%m:%S');
const tomorrow = new Date(Date.now() + 1000 * 60 * 60 * 24);

console.log(tomorrow); // 'Mon Apr 04 2022 12:57:15 GMT-0400 (Eastern Daylight Time)'
console.log(timeFormat(tomorrow)); // 2022-04-04 12:57:15