0.0.4 • Published 2 years ago

lingcod v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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 { createServer } from 'http';
import { createRequestListener } from 'lingcod/server';

const requestListener = createRequestListener('./public/');
const httpServer = createServer(requestListener);

httpServer.listen(8080);
import { deepClone } from 'lingcod/object';

const original = { a: 1, b: { c: 2 } };
const copy = deepClone(original);

original.b.c = 3; // { a: 1, b: { c: 3 } }
console.log(copy); // { a: 1, b: { c: 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
0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago

0.0.0

2 years ago