From e29ce4583c20f3a63fbeecd5f1f83b9a5e025385 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 7 Oct 2020 03:53:10 +0300 Subject: [PATCH] started work on docs... Signed-off-by: Alex A. Naanou --- README.md | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ test.js | 19 ++++++ 2 files changed, 190 insertions(+) diff --git a/README.md b/README.md index e69de29..7d87821 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,171 @@ +# types.js + +A library of JavaScript type extensions, types and type utilities. + +- [types.js](#typesjs) + - [Built-in type extenstions](#built-in-type-extenstions) + - [`Object`](#object) + - [`Object.deepKeys(..)`](#objectdeepkeys) + - [`Object.match(..)`](#objectmatch) + - [`Object.matchPartial(..)`](#objectmatchpartial) + - [`Object.flatCopy(..)`](#objectflatcopy) + - [`.run(..)`](#objectrun) + - [`Array`](#array) + - [`.first(..)` / `.last(..)`](#arrayfirst--arraylast) + - [`.compact()`](#arraycompact) + - [`.len`](#arraylen) + - [`.toKeys(..)`](#arraytokeys) + - [`.toMap(..)`](#arraytomap) + - [`.unique(..)` / `.tailUnique(..)`](#arrayunique--arraytailunique) + - [`.cmp(..)`](#arraycmp) + - [`.setCmp(..)`](#arraysetcmp) + - [`.sortAs(..)`](#arraysortas) + - [`.inplaceSortAs(..)`](#arrayinplacesortas) + - [`.mapChunks(..)`](#arraymapchunks) + - [`.filterChunks(..)`](#arrayfilterchunks) + - [`.reduceChunks(..)`](#arrayreducechunks) + - [`Array` (polyfill)](#array-polyfill) + - [`.flat()`](#arrayflat) + - [`.includes()`](#arrayincludes) + - [`Set`](#set) + - [`.unite(..)`](#setunite) + - [`.intersect(..)`](#setintersect) + - [`.subtract(..)`](#setsubtract) + - [`Date`](#date) + - [`Date.timeStamp(..)`](#datetimestamp) + - [`Date.fromTimeStamp(..)`](#datefromtimestamp) + - [`Date.str2ms(..)`](#datestr2ms) + - [`.toShortDate(..)`](#datetoshortdate) + - [`.getTimeStamp(..)`](#dategettimestamp) + - [`.setTimeStamp(..)`](#datesettimestamp) + - [`String`](#string) + - [`.capitalize()`](#stringcapitalize) + - [`RegExp`](#regexp) + - [`RegExp.quoteRegExp(..)`](#regexpquoteregexp) + - [Containers](#containers) + - [`UniqueKeyMap()` (`Map`)](#uniquekeymap-map) + - [`.reset(..)`](#unique-key-mapreset) + - [`.uniqueKey(..)`](#unique-key-mapuniquekey) + - [`.rename(..)`](#unique-key-maprename) + - [`.keysOf(..)`](#unique-key-mapkeysof) + +## Built-in type extenstions + +### `Object` + +#### `Object.deepKeys(..)` + +#### `Object.match(..)` + +#### `Object.matchPartial(..)` + +#### `Object.flatCopy(..)` + +#### `.run(..)` + + +### `Array` + +#### `.first(..)` / `.last(..)` + +Get or set the first/last items of ``. + + +#### `.compact()` + +Generate a compact `` from a sparse ``, i.e. removing all +the empty slots. + + +#### `.len` + +Number of non-empty slots/elements in ``. + + +#### `.toKeys(..)` + +#### `.toMap(..)` + +#### `.unique(..)` / `.tailUnique(..)` + +Generate an array with all duplicate elements removed. + +#### `.cmp(..)` + +#### `.setCmp(..)` + +#### `.sortAs(..)` + +#### `.inplaceSortAs(..)` + +#### `.mapChunks(..)` + +#### `.filterChunks(..)` + +#### `.reduceChunks(..)` + + +### `Array` (polyfill) + +#### `.flat()` + +#### `.includes()` + + +### `Set` + +#### `.unite(..)` + +#### `.intersect(..)` + +#### `.subtract(..)` + + +### `Date` + +#### `Date.timeStamp(..)` + +#### `Date.fromTimeStamp(..)` + +#### `Date.str2ms(..)` + +#### `.toShortDate(..)` + +#### `.getTimeStamp(..)` + +#### `.setTimeStamp(..)` + + +### `String` + +#### `.capitalize()` + + +### `RegExp` + +#### `RegExp.quoteRegExp(..)` + + +## Containers + +### `UniqueKeyMap()` (`Map`) + +`UniqueKeyMap` extends the `Map` constructor. + +XXX + +For more info on `Map` see: +https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map + +#### `.reset(..)` + +#### `.uniqueKey(..)` + +#### `.rename(..)` + +#### `.keysOf(..)` + + + + + \ No newline at end of file diff --git a/test.js b/test.js index 6ae400c..012d856 100755 --- a/test.js +++ b/test.js @@ -67,7 +67,23 @@ var cases = test.Cases({ // - reduceChunks Array: function(assert){ }, + + // Set.js + // - unite + // - intersect + // - subtract + Array: function(assert){ + }, + String: function(assert){ + assert(''.capitalize() == '') + assert('a'.capitalize() == 'A') + assert('abc'.capitalize() == 'Abc') + }, + + RegExp: function(assert){ + }, + // Date.js Date: function(assert){ var d = new Date() @@ -106,6 +122,9 @@ var cases = test.Cases({ assert(Date.str2ms('2hour') == 2*60*60*1000, 'Date.str2ms("1hour")') assert(Date.str2ms('2 Hour') == 2*60*60*1000, 'Date.str2ms("1 Hour")') assert(Date.str2ms('2 hours') == 2*60*60*1000, 'Date.str2ms("1 hours")') + + assert(Number.isNaN(Date.str2ms('moo')), 'Date.str2ms("moo")') + assert(Number.isNaN(Date.str2ms('123 moo')), 'Date.str2ms("moo")') }, // containers.js