From 606bed3f92862d543e1aba18721e46d8857c64bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Zalewski?= Date: Fri, 3 Jan 2020 13:57:27 +0100 Subject: [PATCH 1/7] Enforce strict TypeScript --- compile.js | 2 ++ tsconfig.json | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/compile.js b/compile.js index b2eeff10..2fb6fe2f 100644 --- a/compile.js +++ b/compile.js @@ -68,6 +68,8 @@ const main = async cwd => { "--skipLibCheck", "--module ES6", "--target ES2020", + "--noImplicitAny", + "--strict", "-d", quotePath(path.posix.normalize(filePath)) ]; diff --git a/tsconfig.json b/tsconfig.json index bc4c76cd..85e96f61 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,9 +2,10 @@ "compilerOptions": { "module": "ES6", "noImplicitAny": true, - "removeComments": true, "preserveConstEnums": true, + "removeComments": true, "sourceMap": true, + "strict": true, "target": "ES2020" } } From 86a07407724fd9deb322c38ada7dcc51f1d0d5c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Zalewski?= Date: Fri, 3 Jan 2020 14:01:21 +0100 Subject: [PATCH 2/7] Adjust typings to pass TypeScript strict checks --- array/differs.ts | 8 +++-- array/first.ts | 2 +- array/second.ts | 2 +- async/debounce.ts | 2 +- date/byDateWithFallback.ts | 12 +++++-- date/clamp.ts | 4 ++- date/dateDiff.ts | 2 +- date/dateInRange.ts | 4 ++- date/dayRange.ts | 2 +- date/daysInMonths.ts | 30 +++++++++-------- date/daysInYear.ts | 2 +- date/displayMonth.ts | 2 +- date/displayTime.ts | 2 +- date/endOfDay.ts | 6 +++- date/formatDate.ts | 2 +- date/formatDateTime.ts | 2 +- date/formatDisplayDate.ts | 2 +- date/formatDuration.ts | 2 +- date/formatTime.ts | 6 ++-- date/fromDays.ts | 2 +- date/fromHours.md | 2 +- date/fromHours.ts | 2 +- date/fromMinutes.ts | 2 +- date/fromSeconds.ts | 2 +- date/joinDateTime.ts | 2 +- date/leapYear.ts | 2 +- date/offsetByBit.ts | 2 +- date/splitDateTime.ts | 2 +- date/startOfDay.ts | 6 +++- date/subtractDays.ts | 2 +- date/toDate.ts | 2 +- date/toDates.ts | 2 +- date/toDays.ts | 2 +- date/toHours.ts | 2 +- date/toISO.ts | 2 +- date/toISOFromLocalDateTime.ts | 2 +- date/toLocalDateTime.ts | 2 +- date/toMinutes.ts | 2 +- date/toSeconds.ts | 2 +- date/valid.ts | 2 +- debug/assert.ts | 2 +- debug/diff.ts | 29 ++++++++++------- encoding/base64url.ts | 55 +++++++++++++++----------------- function/memoizeWith.ts | 6 ++-- is/byte.ts | 4 ++- is/index.ts | 3 ++ is/integer.ts | 4 ++- is/normal.ts | 3 +- is/number.ts | 7 +++- math/median.ts | 2 +- object/merge.ts | 8 ++--- object/sort.ts | 2 +- query/serialize.ts | 4 +-- range/empty.ts | 2 +- range/equals.ts | 3 +- range/length.ts | 2 +- vector2/cross.ts | 3 +- vector2/dot.ts | 3 +- vector2/normalize.ts | 6 ++-- web/events/openInNewTabIntent.ts | 13 ++++++-- 60 files changed, 176 insertions(+), 125 deletions(-) diff --git a/array/differs.ts b/array/differs.ts index 51d620fd..e46087c4 100644 --- a/array/differs.ts +++ b/array/differs.ts @@ -1,5 +1,9 @@ +const nonNullable = (val: T): val is NonNullable => + val !== undefined || val !== null; + export default (xs?: any[], ys?: any[]) => Boolean(!xs && ys) || Boolean(!ys && xs) || - xs.length !== ys.length || - xs.some((x, index) => x !== ys[index]); + (nonNullable(ys) && + nonNullable(xs) && + (xs.length !== ys.length || xs.some((x, index) => x !== ys[index]))); diff --git a/array/first.ts b/array/first.ts index 42b96520..82aedf95 100644 --- a/array/first.ts +++ b/array/first.ts @@ -1 +1 @@ -export default ([x]) => x; +export default ([x]: [any]) => x; diff --git a/array/second.ts b/array/second.ts index 41953d02..623dd03d 100644 --- a/array/second.ts +++ b/array/second.ts @@ -1 +1 @@ -export default ([, x]) => x; +export default ([, x]: any[]): any => x; diff --git a/async/debounce.ts b/async/debounce.ts index cb278823..e264751f 100644 --- a/async/debounce.ts +++ b/async/debounce.ts @@ -1,7 +1,7 @@ /* eslint-env browser */ export default (f: { (...args: any[]): any }, wait: number) => { - let timeout; + let timeout: any; return (...args: any[]) => { const resolve = () => { diff --git a/date/byDateWithFallback.ts b/date/byDateWithFallback.ts index 3c6c5296..85c42ed5 100644 --- a/date/byDateWithFallback.ts +++ b/date/byDateWithFallback.ts @@ -1,6 +1,12 @@ -export default now => ( - { endedAt: aEnd, startedAt: aStart }, - { endedAt: bEnd, startedAt: bStart } +export default (now: Date | string | number) => ( + { + endedAt: aEnd, + startedAt: aStart + }: { endedAt: Date | string | number; startedAt: Date | string | number }, + { + endedAt: bEnd, + startedAt: bStart + }: { endedAt: Date | string | number; startedAt: Date | string | number } ) => { const aEndDate = new Date(aEnd || now); const aStartDate = new Date(aStart || now); diff --git a/date/clamp.ts b/date/clamp.ts index 51fd80cd..e8115276 100644 --- a/date/clamp.ts +++ b/date/clamp.ts @@ -1,4 +1,6 @@ -export default (min, max) => dateStringOrDate => { +export default (min: Date | number, max: Date | number) => ( + dateStringOrDate: string | number | Date +) => { const date = new Date(dateStringOrDate); const clamped = new Date( diff --git a/date/dateDiff.ts b/date/dateDiff.ts index 2e4d2ce6..d8e585a3 100644 --- a/date/dateDiff.ts +++ b/date/dateDiff.ts @@ -1,4 +1,4 @@ -export default (a, b) => { +export default (a: string | number | Date, b: string | number | Date) => { const d1 = new Date(a); const d2 = new Date(b); diff --git a/date/dateInRange.ts b/date/dateInRange.ts index 29997ef7..25859e6c 100644 --- a/date/dateInRange.ts +++ b/date/dateInRange.ts @@ -1,4 +1,6 @@ -export default (from, to) => (date = new Date()) => { +export default (from: string | number | Date, to: string | number | Date) => ( + date = new Date() +) => { const dateTime = new Date(date).getTime(); const fromTime = new Date(from).getTime(); const toTime = new Date(to).getTime(); diff --git a/date/dayRange.ts b/date/dayRange.ts index 62c9f654..cab26edc 100644 --- a/date/dayRange.ts +++ b/date/dayRange.ts @@ -10,7 +10,7 @@ export default ({ local = true, now = new Date(), timezoneOffset = 0 -}) => date => { +}) => (date?: string | number | Date) => { const convert = iso ? toISO : toISOFromLocalDateTime; const [start] = splitDateTime( diff --git a/date/daysInMonths.ts b/date/daysInMonths.ts index 2ad5657f..571a118f 100644 --- a/date/daysInMonths.ts +++ b/date/daysInMonths.ts @@ -1,14 +1,16 @@ -export default leapYear => [ - 31, - leapYear ? 29 : 28, - 31, - 30, - 31, - 30, - 31, - 31, - 30, - 31, - 30, - 31 -]; +export default ( + leapYear: boolean +): [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number +] => [31, leapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; diff --git a/date/daysInYear.ts b/date/daysInYear.ts index 13c489da..4a364b99 100644 --- a/date/daysInYear.ts +++ b/date/daysInYear.ts @@ -2,4 +2,4 @@ import sum from "../array/sum"; import daysInMonths from "./daysInMonths"; import leapYear from "./leapYear"; -export default year => sum(daysInMonths(leapYear(year))); +export default (year: number) => sum(daysInMonths(leapYear(year))); diff --git a/date/displayMonth.ts b/date/displayMonth.ts index 83a1e0b6..29e50e5b 100644 --- a/date/displayMonth.ts +++ b/date/displayMonth.ts @@ -1,3 +1,3 @@ import monthNames from "./monthNames"; -export default monthIndex => monthNames[monthIndex % 12]; +export default (monthIndex: number) => monthNames[monthIndex % 12]; diff --git a/date/displayTime.ts b/date/displayTime.ts index fc78bc18..b1bfe6fc 100644 --- a/date/displayTime.ts +++ b/date/displayTime.ts @@ -1,4 +1,4 @@ -export default (source, showSeconds) => { +export default (source: [number, number, number], showSeconds: boolean) => { const [hours, minutes, seconds] = source.map(_ => _ + ""); const padded = [ diff --git a/date/endOfDay.ts b/date/endOfDay.ts index 71f92a0f..546a0024 100644 --- a/date/endOfDay.ts +++ b/date/endOfDay.ts @@ -1,6 +1,10 @@ import toLocalDateTime from "./toLocalDateTime"; -export default (date, timezoneOffset = 0, local = true) => { +export default ( + date: string | number | Date, + timezoneOffset = 0, + local = true +) => { const newDate = new Date(date); newDate.setHours(24, 0, 0, 0); diff --git a/date/formatDate.ts b/date/formatDate.ts index f6fcac30..50bd88b1 100644 --- a/date/formatDate.ts +++ b/date/formatDate.ts @@ -1,6 +1,6 @@ import toLocalDateTime from "./toLocalDateTime"; -export default (sourceDate, timezoneOffset = 0) => { +export default (sourceDate: Date, timezoneOffset: number = 0) => { const localDate = toLocalDateTime(sourceDate, timezoneOffset); const [m, a, y] = [ diff --git a/date/formatDateTime.ts b/date/formatDateTime.ts index a350c841..94cd878c 100644 --- a/date/formatDateTime.ts +++ b/date/formatDateTime.ts @@ -1,7 +1,7 @@ import formatDate from "./formatDate"; import formatTime from "./formatTime"; -export default (sourceDate, showSeconds = false, timezoneOffset = 0) => { +export default (sourceDate: Date, showSeconds = false, timezoneOffset = 0) => { const date = formatDate(sourceDate, timezoneOffset); const time = formatTime(sourceDate, showSeconds, timezoneOffset); diff --git a/date/formatDisplayDate.ts b/date/formatDisplayDate.ts index 70eddb0c..38fb8ab9 100644 --- a/date/formatDisplayDate.ts +++ b/date/formatDisplayDate.ts @@ -1,7 +1,7 @@ import toLocalDateTime from "./toLocalDateTime"; import displayMonth from "./displayMonth"; -export default (sourceDate, showDay = false, timezoneOffset = 0) => { +export default (sourceDate: Date, showDay = false, timezoneOffset = 0) => { const localDate = toLocalDateTime(sourceDate, timezoneOffset); const day = localDate.getDate(); const monthIndex = localDate.getMonth(); diff --git a/date/formatDuration.ts b/date/formatDuration.ts index bda1bc18..9401437c 100644 --- a/date/formatDuration.ts +++ b/date/formatDuration.ts @@ -5,7 +5,7 @@ import toMinutes from "./toMinutes"; import toSeconds from "./toSeconds"; import displayTime from "./displayTime"; -export default (duration, showSeconds = false) => { +export default (duration: number, showSeconds = false) => { const hours = Math.floor(toHours(duration)); const minutes = Math.floor(toMinutes(duration - fromHours(hours))); diff --git a/date/formatTime.ts b/date/formatTime.ts index 26e55f00..e657b22a 100644 --- a/date/formatTime.ts +++ b/date/formatTime.ts @@ -1,14 +1,14 @@ import toLocalDateTime from "./toLocalDateTime"; import displayTime from "./displayTime"; -export default (sourceDate, showSeconds = false, timezoneOffset = 0) => { +export default (sourceDate: Date, showSeconds = false, timezoneOffset = 0) => { const localDate = toLocalDateTime(sourceDate, timezoneOffset); - const source = [ + const [hours, minutes, seconds] = [ localDate.getUTCHours(), localDate.getUTCMinutes(), localDate.getUTCSeconds() ]; - return displayTime(source, showSeconds); + return displayTime([hours, minutes, seconds], showSeconds); }; diff --git a/date/fromDays.ts b/date/fromDays.ts index ea8d490e..a30ed404 100644 --- a/date/fromDays.ts +++ b/date/fromDays.ts @@ -1,3 +1,3 @@ import fromHours from "./fromHours"; -export default days => fromHours(days * 24); +export default (days: number) => fromHours(days * 24); diff --git a/date/fromHours.md b/date/fromHours.md index ded6d442..a8b3f21f 100644 --- a/date/fromHours.md +++ b/date/fromHours.md @@ -4,6 +4,6 @@ ```typescript -(hours: any) => number +(hours: number) => number ``` diff --git a/date/fromHours.ts b/date/fromHours.ts index 6a5f9617..58d75a47 100644 --- a/date/fromHours.ts +++ b/date/fromHours.ts @@ -1,3 +1,3 @@ import fromMinutes from "./fromMinutes"; -export default hours => fromMinutes(hours * 60); +export default (hours: number) => fromMinutes(hours * 60); diff --git a/date/fromMinutes.ts b/date/fromMinutes.ts index 6e32741a..26e5d2ec 100644 --- a/date/fromMinutes.ts +++ b/date/fromMinutes.ts @@ -1,3 +1,3 @@ import fromSeconds from "./fromSeconds"; -export default minutes => fromSeconds(minutes * 60); +export default (minutes: number) => fromSeconds(minutes * 60); diff --git a/date/fromSeconds.ts b/date/fromSeconds.ts index c0770d78..f19d1e92 100644 --- a/date/fromSeconds.ts +++ b/date/fromSeconds.ts @@ -1 +1 @@ -export default seconds => seconds * 1000; +export default (seconds: number) => seconds * 1000; diff --git a/date/joinDateTime.ts b/date/joinDateTime.ts index 328ef7c9..23c1b067 100644 --- a/date/joinDateTime.ts +++ b/date/joinDateTime.ts @@ -1 +1 @@ -export default (...xs) => xs.join("T"); +export default (...xs: string[]) => xs.join("T"); diff --git a/date/leapYear.ts b/date/leapYear.ts index 62ab3314..9009ddcd 100644 --- a/date/leapYear.ts +++ b/date/leapYear.ts @@ -1 +1 @@ -export default year => new Date(year, 1, 29).getMonth() === 1; +export default (year: number) => new Date(year, 1, 29).getMonth() === 1; diff --git a/date/offsetByBit.ts b/date/offsetByBit.ts index 6df9dd14..0fb12447 100644 --- a/date/offsetByBit.ts +++ b/date/offsetByBit.ts @@ -2,4 +2,4 @@ import fromSeconds from "./fromSeconds"; const SECOND = fromSeconds(1); -export default date => new Date(date - SECOND); +export default (date: Date | number) => new Date(date.valueOf() - SECOND); diff --git a/date/splitDateTime.ts b/date/splitDateTime.ts index 0b871afb..f781a075 100644 --- a/date/splitDateTime.ts +++ b/date/splitDateTime.ts @@ -1 +1 @@ -export default dateTimeString => dateTimeString.split("T"); +export default (dateTimeString: string) => dateTimeString.split("T"); diff --git a/date/startOfDay.ts b/date/startOfDay.ts index 82289a4b..c32f86d5 100644 --- a/date/startOfDay.ts +++ b/date/startOfDay.ts @@ -1,6 +1,10 @@ import toLocalDateTime from "./toLocalDateTime"; -export default (date, timezoneOffset = 0, local = true) => { +export default ( + date: string | number | Date, + timezoneOffset = 0, + local = true +) => { const newDate = new Date(date); newDate.setHours(0, 0, 0, 0); diff --git a/date/subtractDays.ts b/date/subtractDays.ts index 3dbbb505..0efa06f3 100644 --- a/date/subtractDays.ts +++ b/date/subtractDays.ts @@ -1,4 +1,4 @@ -export default (sourceDate, numberOfDays) => { +export default (sourceDate: string | number | Date, numberOfDays: number) => { const date = new Date(sourceDate); date.setDate(date.getDate() - numberOfDays); diff --git a/date/toDate.ts b/date/toDate.ts index 04b7bb21..987c7e9c 100644 --- a/date/toDate.ts +++ b/date/toDate.ts @@ -1,4 +1,4 @@ -export default date => { +export default (date: Date) => { const day = date.getDate(); const month = date.getMonth() + 1; const year = date.getFullYear(); diff --git a/date/toDates.ts b/date/toDates.ts index 8fb2e180..6490b81b 100644 --- a/date/toDates.ts +++ b/date/toDates.ts @@ -1 +1 @@ -export default xs => xs.map(x => new Date(x)); +export default (xs: (string | number | Date)[]) => xs.map(x => new Date(x)); diff --git a/date/toDays.ts b/date/toDays.ts index 1d9e7132..cffed990 100644 --- a/date/toDays.ts +++ b/date/toDays.ts @@ -1,3 +1,3 @@ import toHours from "./toHours"; -export default milliseconds => toHours(milliseconds) / 24; +export default (milliseconds: number) => toHours(milliseconds) / 24; diff --git a/date/toHours.ts b/date/toHours.ts index 44509b4b..bec1f273 100644 --- a/date/toHours.ts +++ b/date/toHours.ts @@ -1,3 +1,3 @@ import toMinutes from "./toMinutes"; -export default milliseconds => toMinutes(milliseconds) / 60; +export default (milliseconds: number) => toMinutes(milliseconds) / 60; diff --git a/date/toISO.ts b/date/toISO.ts index 9ac56e00..12d68a84 100644 --- a/date/toISO.ts +++ b/date/toISO.ts @@ -1 +1 @@ -export default x => x.toISOString(); +export default (x: Date) => x.toISOString(); diff --git a/date/toISOFromLocalDateTime.ts b/date/toISOFromLocalDateTime.ts index f4d527df..e3d6016f 100644 --- a/date/toISOFromLocalDateTime.ts +++ b/date/toISOFromLocalDateTime.ts @@ -1,6 +1,6 @@ import fromMinutes from "./fromMinutes"; -export default date => +export default (date: Date) => new Date( date.valueOf() - fromMinutes(date.getTimezoneOffset()) ).toISOString(); diff --git a/date/toLocalDateTime.ts b/date/toLocalDateTime.ts index c739d259..7d84958d 100644 --- a/date/toLocalDateTime.ts +++ b/date/toLocalDateTime.ts @@ -1,4 +1,4 @@ import fromMinutes from "./fromMinutes"; -export default (date, timezoneOffset = 0) => +export default (date: Date, timezoneOffset: number = 0) => new Date(date.valueOf() - fromMinutes(timezoneOffset)); diff --git a/date/toMinutes.ts b/date/toMinutes.ts index 3ef8dcca..fd8f8a28 100644 --- a/date/toMinutes.ts +++ b/date/toMinutes.ts @@ -1,3 +1,3 @@ import toSeconds from "./toSeconds"; -export default milliseconds => toSeconds(milliseconds) / 60; +export default (milliseconds: number) => toSeconds(milliseconds) / 60; diff --git a/date/toSeconds.ts b/date/toSeconds.ts index 39f86994..eca6e443 100644 --- a/date/toSeconds.ts +++ b/date/toSeconds.ts @@ -1 +1 @@ -export default milliseconds => milliseconds / 1000; +export default (milliseconds: number) => milliseconds / 1000; diff --git a/date/valid.ts b/date/valid.ts index 83119e28..0f82e166 100644 --- a/date/valid.ts +++ b/date/valid.ts @@ -1 +1 @@ -export default date => date && date instanceof Date; +export default (date?: any): boolean => (date ? date instanceof Date : false); diff --git a/debug/assert.ts b/debug/assert.ts index 5638c800..ef948a26 100644 --- a/debug/assert.ts +++ b/debug/assert.ts @@ -22,7 +22,7 @@ const assert = ( } }; -export const throws = (f: () => void): Error => { +export const throws = (f: () => void): Error | undefined => { try { f(); diff --git a/debug/diff.ts b/debug/diff.ts index 4061dada..85786ec3 100644 --- a/debug/diff.ts +++ b/debug/diff.ts @@ -40,7 +40,10 @@ const compareValues = (value1: any, value2: any) => { return VALUE_UPDATED; }; -const diff = (obj1: object, obj2: object) => { +const diff = ( + obj1?: { [index: string]: any }, + obj2?: { [index: string]: any } +): object => { if (isValue(obj1) || isValue(obj2)) { const comparisonResult = compareValues(obj1, obj2); @@ -49,31 +52,33 @@ const diff = (obj1: object, obj2: object) => { type: comparisonResult, data: [obj1, obj2] } - : null; + : {}; } - const result = {}; + const result: { [index: string]: any } = {}; for (const key in obj1) { - if (isFunction(obj1[key])) { + const value1 = obj1[key]; + + if (isFunction(value1)) { continue; } - let value2 = undefined; - - if (isDefined(obj2[key])) { - value2 = obj2[key]; - } + const value2 = obj2 ? obj2[key] : undefined; - result[key] = diff(obj1[key], value2); + result[key] = diff(value1, value2); } for (const key in obj2) { - if (isFunction(obj2[key]) || isDefined(result[key])) { + const value2 = obj2[key]; + + const existingValue = result[key]; + + if (isFunction(value2) || isDefined(existingValue)) { continue; } - result[key] = diff(undefined, obj2[key]); + result[key] = diff(undefined, value2); } return filter( diff --git a/encoding/base64url.ts b/encoding/base64url.ts index 75b5c93d..98c75bc4 100644 --- a/encoding/base64url.ts +++ b/encoding/base64url.ts @@ -1,23 +1,34 @@ /* eslint-env browser, node */ +export interface EncodeContext { + btoa: (byteString: string) => string; + TextEncoder: new () => { + encode: { (input?: string): Uint8Array }; + }; +} + +export interface DecodeContext { + atob: (byteString: string) => string; + TextDecoder: new (encoding: string) => { + decode: (input?: Uint8Array) => string; + }; +} + const toArray = (typedArray: Uint8Array): number[] => [...typedArray]; export const toByteString = (bytes: number[]) => bytes.map(_ => String.fromCharCode(_)).join(""); -export const fromByteString = (byteString: string) => - [...byteString].map(_ => _.codePointAt(0)); +export const fromByteString = (byteString: string): number[] => + [...byteString].map(_ => _.codePointAt(0) || 0); const ENCODING = "utf-8"; const btoaImplementation = ( text: string, - context: { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: { (input?: string): Uint8Array }; - }; - } = typeof window !== "undefined" ? window : undefined + context: EncodeContext | undefined = typeof window !== "undefined" + ? window + : undefined ) => context ? context.btoa( @@ -27,12 +38,9 @@ const btoaImplementation = ( const atobImplementation = ( text: string, - context: { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array) => string; - }; - } = typeof window !== "undefined" ? window : undefined + context: DecodeContext | undefined = typeof window !== "undefined" + ? window + : undefined ) => context ? new context.TextDecoder(ENCODING).decode( @@ -52,15 +60,8 @@ export const encode = ( .replace(/\+/g, "-") .replace(/\//g, "_"); -export const decode = ( - text: string, - context?: { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array) => string; - }; - } -) => atobImplementation(text.replace(/-/g, "+").replace(/_/g, "/"), context); +export const decode = (text: string, context?: DecodeContext) => + atobImplementation(text.replace(/-/g, "+").replace(/_/g, "/"), context); export const toBase64Url = (base64: string) => base64.replace(/\+/g, "-").replace(/\//g, "_"); @@ -68,13 +69,7 @@ export const toBase64Url = (base64: string) => export const fromBase64Url = (base64: string) => base64.replace(/-/g, "+").replace(/_/g, "/"); -export const encodeBytes = ( - bytes: number[], - context?: { - btoa: (byteString: string) => string; - TextEncoder: new () => { encode: (input?: string) => Uint8Array }; - } -) => { +export const encodeBytes = (bytes: number[], context?: EncodeContext) => { const sourceText = toByteString(bytes); return encode(sourceText, context); diff --git a/function/memoizeWith.ts b/function/memoizeWith.ts index 099dcf22..12f09e9a 100644 --- a/function/memoizeWith.ts +++ b/function/memoizeWith.ts @@ -1,10 +1,10 @@ export default (equals: (x: any, y: any) => boolean) => ( f: (...xs: any[]) => any ) => { - let memoized = undefined; - let memoizedArgs = undefined; + let memoized: any = undefined; + let memoizedArgs: any[] | undefined = undefined; - return (...args) => { + return (...args: any[]) => { if (memoized && equals(args, memoizedArgs)) { return memoized; } diff --git a/is/byte.ts b/is/byte.ts index 6afe9f0d..7eded0d0 100644 --- a/is/byte.ts +++ b/is/byte.ts @@ -1,3 +1,5 @@ import integer from "./integer"; +import nonNullable from "./nonNullable"; -export default (x?: number) => integer(x) && x >= 0 && x <= 255; +export default (x?: number) => + nonNullable(x) && integer(x) && x >= 0 && x <= 255; diff --git a/is/index.ts b/is/index.ts index 0a1a25d4..524c029d 100644 --- a/is/index.ts +++ b/is/index.ts @@ -4,6 +4,7 @@ import date from "./date"; import defined from "./defined"; import _function from "./function"; import integer from "./integer"; +import nonNullable from "./nonNullable"; import normal from "./normal"; import number from "./number"; import object from "./object"; @@ -16,6 +17,7 @@ export { defined, _function, integer, + nonNullable, normal, number, object, @@ -29,6 +31,7 @@ export default { defined, _function, integer, + nonNullable, normal, number, object, diff --git a/is/integer.ts b/is/integer.ts index 1cba338e..47aa7d65 100644 --- a/is/integer.ts +++ b/is/integer.ts @@ -1,3 +1,5 @@ import number from "./number"; +import nonNullable from "./nonNullable"; -export default (x?: number) => number(x) && Math.floor(x) === x; +export default (x?: number) => + nonNullable(x) && number(x) && Math.floor(x) === x; diff --git a/is/normal.ts b/is/normal.ts index 2dc02f68..c75bd259 100644 --- a/is/normal.ts +++ b/is/normal.ts @@ -1,3 +1,4 @@ import number from "./number"; +import nonNullable from "./nonNullable"; -export default (x?: number) => number(x) && x >= 0 && x <= 1; +export default (x?: number) => nonNullable(x) && number(x) && x >= 0 && x <= 1; diff --git a/is/number.ts b/is/number.ts index 102e7de3..f67dc8e9 100644 --- a/is/number.ts +++ b/is/number.ts @@ -1,2 +1,7 @@ +import nonNullable from "./nonNullable"; + export default (x?: any) => - typeof x === "number" && !Number.isNaN(x) && Number.isFinite(x); + nonNullable(x) && + typeof x === "number" && + !Number.isNaN(x) && + Number.isFinite(x); diff --git a/math/median.ts b/math/median.ts index a34e2de1..b332b629 100644 --- a/math/median.ts +++ b/math/median.ts @@ -1,7 +1,7 @@ import sort from "../array/sort"; import subtract from "./subtract"; -export default (xs?: number[]): number => { +export default (xs?: number[]): number | undefined => { if (!xs || xs.length === 0) { return undefined; } diff --git a/object/merge.ts b/object/merge.ts index 7664e921..157c8c3a 100644 --- a/object/merge.ts +++ b/object/merge.ts @@ -1,13 +1,13 @@ +import isNonNullable from "../is/nonNullable"; import isObject from "../is/object"; import map from "./map"; -const isNonNullishObject = (x?: object) => - x !== undefined && x !== null && isObject(x); +const isNonNullableObject = (x?: object) => isNonNullable(x) && isObject(x); -const merge = (a: object, b: object): object => ({ +const merge = (a: { [index: string]: any }, b: object): object => ({ ...a, ...map((value, key) => - isNonNullishObject(value) && isNonNullishObject(a[key]) + isNonNullableObject(value) && isNonNullableObject(a[key]) ? merge(a[key], value) : value )(b) diff --git a/object/sort.ts b/object/sort.ts index ce7b9167..31e9848e 100644 --- a/object/sort.ts +++ b/object/sort.ts @@ -2,5 +2,5 @@ import sort from "../array/sort"; import entries from "./entries"; import fromEntries from "./fromEntries"; -export default f => xs => +export default (f: (a: any, b: any) => number) => (xs: object): object => fromEntries(sort(([, a], [, b]) => f(a, b))(entries(xs))); diff --git a/query/serialize.ts b/query/serialize.ts index 91ce6262..bd01c100 100644 --- a/query/serialize.ts +++ b/query/serialize.ts @@ -1,9 +1,9 @@ import entries from "../object/entries"; -export default (xs = {}) => +export default (xs: { [index: string]: any } = {}): string => entries(xs) .filter(([, value]) => Boolean(value) || value === 0) - .map(pair => pair.map(encodeURIComponent)) + .map(pair => pair.map(value => encodeURIComponent(value))) .reduce( (acc, [key, value]) => [ ...acc, diff --git a/range/empty.ts b/range/empty.ts index 71065567..d607d8aa 100644 --- a/range/empty.ts +++ b/range/empty.ts @@ -1 +1 @@ -export default ([min, max]) => min === max; +export default ([min, max]: [number, number]): boolean => min === max; diff --git a/range/equals.ts b/range/equals.ts index ab5c1860..2527842e 100644 --- a/range/equals.ts +++ b/range/equals.ts @@ -1 +1,2 @@ -export default ([a, b], [c, d]) => a === c && b === d; +export default ([a, b]: [number, number], [c, d]: [number, number]): boolean => + a === c && b === d; diff --git a/range/length.ts b/range/length.ts index 3961ffcd..1963a21b 100644 --- a/range/length.ts +++ b/range/length.ts @@ -1 +1 @@ -export default ([min, max]) => max - min; +export default ([min, max]: [number, number]): number => max - min; diff --git a/vector2/cross.ts b/vector2/cross.ts index 327ae4d7..6b3fe15c 100644 --- a/vector2/cross.ts +++ b/vector2/cross.ts @@ -1 +1,2 @@ -export default ([a, b], [c, d]) => a * d - b * c; +export default ([a, b]: [number, number], [c, d]: [number, number]): number => + a * d - b * c; diff --git a/vector2/dot.ts b/vector2/dot.ts index c18e85fe..bc211e9e 100644 --- a/vector2/dot.ts +++ b/vector2/dot.ts @@ -1 +1,2 @@ -export default ([a, b], [c, d]) => a * c + b * d; +export default ([a, b]: [number, number], [c, d]: [number, number]): number => + a * c + b * d; diff --git a/vector2/normalize.ts b/vector2/normalize.ts index 0a6954ab..d9c9da03 100644 --- a/vector2/normalize.ts +++ b/vector2/normalize.ts @@ -1,7 +1,9 @@ import length from "./length"; -export default (vector: [number, number]) => { +export default (vector: [number, number]): [number, number] => { const magnitude = length(vector); - return magnitude !== 0 ? vector.map(_ => _ / magnitude) : vector; + const [x, y] = vector; + + return magnitude !== 0 ? [x / magnitude, y / magnitude] : vector; }; diff --git a/web/events/openInNewTabIntent.ts b/web/events/openInNewTabIntent.ts index a44945b7..5dba11d4 100644 --- a/web/events/openInNewTabIntent.ts +++ b/web/events/openInNewTabIntent.ts @@ -1,2 +1,11 @@ -export default ({ button, ctrlKey, metaKey, shiftKey }) => - Boolean(ctrlKey || shiftKey || metaKey || button === 1); +export default ({ + button, + ctrlKey, + metaKey, + shiftKey +}: { + button?: number; + ctrlKey?: boolean; + metaKey?: boolean; + shiftKey?: boolean; +}) => Boolean(ctrlKey || shiftKey || metaKey || button === 1); From 82ba8b00a60844c16c1f9936f8742937f87429b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Zalewski?= Date: Fri, 3 Jan 2020 14:03:10 +0100 Subject: [PATCH 3/7] Add non-nullable check function --- is/nonNullable.json | 12 ++++++++++++ is/nonNullable.test.ts | 25 +++++++++++++++++++++++++ is/nonNullable.ts | 2 ++ 3 files changed, 39 insertions(+) create mode 100644 is/nonNullable.json create mode 100644 is/nonNullable.test.ts create mode 100644 is/nonNullable.ts diff --git a/is/nonNullable.json b/is/nonNullable.json new file mode 100644 index 00000000..a4eb5f36 --- /dev/null +++ b/is/nonNullable.json @@ -0,0 +1,12 @@ +{ + "name": "nonNullable", + "description": "Checks and asserts the given value is not a null or undefined.", + "signature": "(val: T) => val is NonNullable", + "examples": [ + { + "language": "javascript", + "content": "nonNullable(); // ⇒ TODO" + } + ], + "questions": ["TODO: List questions that may this function answers."] +} diff --git a/is/nonNullable.test.ts b/is/nonNullable.test.ts new file mode 100644 index 00000000..7e75f049 --- /dev/null +++ b/is/nonNullable.test.ts @@ -0,0 +1,25 @@ +/* eslint-env jest */ +// @ts-ignore ambiguous import +import nonNullable from "./nonNullable.ts"; + +describe("nonNullable", () => { + it("checks and asserts the given value is not a null or undefined", () => { + expect(nonNullable(undefined)).toBe(false); + expect(nonNullable(null)).toBe(false); + + expect(nonNullable(false)).toBe(true); + expect(nonNullable(0)).toBe(true); + expect(nonNullable("")).toBe(true); + + expect(nonNullable({})).toBe(true); + expect(nonNullable([])).toBe(true); + expect(nonNullable(NaN)).toBe(true); + expect(nonNullable(() => {})).toBe(true); + + expect(nonNullable("test")).toBe(true); + expect(nonNullable([1, 2, 3])).toBe(true); + expect(nonNullable({ a: 1, b: 2, c: 3 })).toBe(true); + expect(nonNullable(17.6)).toBe(true); + expect(nonNullable(Math.min)).toBe(true); + }); +}); diff --git a/is/nonNullable.ts b/is/nonNullable.ts new file mode 100644 index 00000000..7979cfd9 --- /dev/null +++ b/is/nonNullable.ts @@ -0,0 +1,2 @@ +export default (val: T): val is NonNullable => + val !== undefined && val !== null; From 74f6d0ed903b26c54f12f0a9a4fbf3d260c7a1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Zalewski?= Date: Fri, 3 Jan 2020 15:05:17 +0100 Subject: [PATCH 4/7] Fix and keep proper coverage after nonNullable changes --- array/differs.test.ts | 2 ++ array/differs.ts | 10 +++++----- debug/diff.test.ts | 7 +++++++ debug/diff.ts | 4 ++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/array/differs.test.ts b/array/differs.test.ts index dde1b8a9..82e1bfbf 100644 --- a/array/differs.test.ts +++ b/array/differs.test.ts @@ -11,6 +11,8 @@ describe("differs", () => { it("short-circuits over parameter presence", () => { expect(differs(null, [1, 2])).toBe(true); expect(differs([2, 3], undefined)).toBe(true); + expect(differs(null, null)).toBe(true); + expect(differs(undefined, undefined)).toBe(true); }); it("compares elements index-wise", () => { diff --git a/array/differs.ts b/array/differs.ts index e46087c4..6228d015 100644 --- a/array/differs.ts +++ b/array/differs.ts @@ -1,9 +1,9 @@ -const nonNullable = (val: T): val is NonNullable => - val !== undefined || val !== null; +import isNonNullable from "../is/nonNullable"; export default (xs?: any[], ys?: any[]) => Boolean(!xs && ys) || Boolean(!ys && xs) || - (nonNullable(ys) && - nonNullable(xs) && - (xs.length !== ys.length || xs.some((x, index) => x !== ys[index]))); + !isNonNullable(ys) || + !isNonNullable(xs) || + xs.length !== ys.length || + xs.some((x, index) => x !== ys[index]); diff --git a/debug/diff.test.ts b/debug/diff.test.ts index 8c62528c..83a9f278 100644 --- a/debug/diff.test.ts +++ b/debug/diff.test.ts @@ -77,4 +77,11 @@ describe("diff", () => { a: { data: [1, 5], type: VALUE_UPDATED } }); }); + + it("detects object deletions", () => { + expect(diff({ a: 1 }, undefined)).toEqual({ + data: [{ a: 1 }, undefined], + type: VALUE_DELETED + }); + }); }); diff --git a/debug/diff.ts b/debug/diff.ts index 85786ec3..a560f2fe 100644 --- a/debug/diff.ts +++ b/debug/diff.ts @@ -44,7 +44,7 @@ const diff = ( obj1?: { [index: string]: any }, obj2?: { [index: string]: any } ): object => { - if (isValue(obj1) || isValue(obj2)) { + if (!obj1 || !obj2 || isValue(obj1) || isValue(obj2)) { const comparisonResult = compareValues(obj1, obj2); return comparisonResult !== VALUE_UNCHANGED @@ -64,7 +64,7 @@ const diff = ( continue; } - const value2 = obj2 ? obj2[key] : undefined; + const value2 = obj2[key]; result[key] = diff(value1, value2); } From 45d272b86f3b657e4db971d54f8dd0711866d57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Zalewski?= Date: Fri, 3 Jan 2020 15:05:30 +0100 Subject: [PATCH 5/7] Regenerate code and docs --- README.md | 290 ++++++++++++++++++----------- array/README.md | 17 +- array/any.json | 2 +- array/any.md | 2 +- array/differs.js | 4 + array/differs.json | 2 +- array/differs.md | 5 +- array/empty.json | 2 +- array/empty.md | 2 +- array/flatten.json | 2 +- array/flatten.md | 2 +- array/second.json | 2 +- array/second.md | 2 +- array/shuffle.json | 2 +- array/shuffle.md | 2 +- array/sort.json | 2 +- array/sort.md | 2 +- async/README.md | 2 +- async/sequence.json | 2 +- async/sequence.md | 2 +- date/README.md | 116 +++++++----- date/byDateWithFallback.json | 2 +- date/byDateWithFallback.md | 10 +- date/clamp.json | 2 +- date/clamp.md | 5 +- date/dateDiff.json | 2 +- date/dateDiff.md | 5 +- date/dateInRange.json | 2 +- date/dateInRange.md | 5 +- date/dayRange.json | 2 +- date/dayRange.md | 10 +- date/daysInMonths.json | 2 +- date/daysInMonths.md | 17 +- date/daysInYear.json | 2 +- date/daysInYear.md | 2 +- date/displayMonth.json | 2 +- date/displayMonth.md | 2 +- date/displayTime.json | 2 +- date/displayTime.md | 5 +- date/endOfDay.json | 2 +- date/endOfDay.md | 2 +- date/formatDate.json | 2 +- date/formatDate.md | 2 +- date/formatDateTime.json | 2 +- date/formatDateTime.md | 2 +- date/formatDisplayDate.json | 2 +- date/formatDisplayDate.md | 2 +- date/formatDuration.json | 2 +- date/formatDuration.md | 2 +- date/formatTime.js | 4 +- date/formatTime.json | 2 +- date/formatTime.md | 2 +- date/fromDays.json | 2 +- date/fromDays.md | 2 +- date/fromHours.json | 2 +- date/fromMinutes.json | 2 +- date/fromMinutes.md | 2 +- date/fromSeconds.json | 2 +- date/fromSeconds.md | 2 +- date/joinDateTime.json | 2 +- date/joinDateTime.md | 2 +- date/leapYear.json | 2 +- date/leapYear.md | 2 +- date/offsetByBit.js | 2 +- date/offsetByBit.json | 2 +- date/offsetByBit.md | 2 +- date/splitDateTime.json | 2 +- date/splitDateTime.md | 2 +- date/startOfDay.json | 2 +- date/startOfDay.md | 2 +- date/subtractDays.json | 2 +- date/subtractDays.md | 5 +- date/toDate.json | 2 +- date/toDate.md | 2 +- date/toDates.json | 2 +- date/toDates.md | 2 +- date/toDays.json | 2 +- date/toDays.md | 2 +- date/toHours.json | 2 +- date/toHours.md | 2 +- date/toISO.json | 2 +- date/toISO.md | 2 +- date/toISOFromLocalDateTime.json | 2 +- date/toISOFromLocalDateTime.md | 2 +- date/toLocalDateTime.json | 2 +- date/toLocalDateTime.md | 2 +- date/toMinutes.json | 2 +- date/toMinutes.md | 2 +- date/toSeconds.json | 2 +- date/toSeconds.md | 2 +- date/valid.js | 2 +- date/valid.json | 2 +- date/valid.md | 2 +- debug/README.md | 13 +- debug/diff.js | 24 +-- debug/diff.json | 2 +- debug/diff.md | 13 +- encoding/README.md | 48 ++--- encoding/base64url.js | 2 +- encoding/base64url.json | 2 +- encoding/base64url.md | 48 ++--- is/README.md | 18 +- is/byte.js | 3 +- is/byte.json | 2 +- is/byte.md | 2 +- is/index.js | 3 + is/integer.js | 3 +- is/integer.json | 2 +- is/integer.md | 2 +- is/nonNullable.js | 1 + is/nonNullable.md | 11 ++ is/normal.js | 3 +- is/normal.json | 2 +- is/normal.md | 2 +- is/number.js | 7 +- math/README.md | 4 +- math/average.json | 2 +- math/average.md | 2 +- math/median.json | 2 +- math/median.md | 2 +- object/README.md | 32 +++- object/any.json | 2 +- object/any.md | 2 +- object/apply.json | 2 +- object/apply.md | 7 +- object/fromEntries.json | 2 +- object/fromEntries.md | 8 +- object/hasKey.json | 2 +- object/hasKey.md | 2 +- object/merge.js | 5 +- object/merge.json | 2 +- object/merge.md | 7 +- object/none.json | 2 +- object/none.md | 2 +- object/sort.json | 2 +- object/sort.md | 4 +- query/README.md | 9 +- query/parse.json | 2 +- query/parse.md | 7 +- query/serialize.js | 2 +- query/serialize.json | 2 +- query/serialize.md | 2 +- range/README.md | 9 +- range/empty.json | 2 +- range/empty.md | 2 +- range/equals.json | 2 +- range/equals.md | 5 +- range/length.json | 2 +- range/length.md | 2 +- string/README.md | 2 +- string/nonEmpty.json | 2 +- string/nonEmpty.md | 2 +- vector2/README.md | 12 +- vector2/cross.json | 2 +- vector2/cross.md | 5 +- vector2/dot.json | 2 +- vector2/dot.md | 5 +- vector2/normalize.js | 3 +- vector2/normalize.json | 2 +- vector2/normalize.md | 2 +- web/README.md | 8 +- web/events/README.md | 8 +- web/events/openInNewTabIntent.json | 2 +- web/events/openInNewTabIntent.md | 8 +- 164 files changed, 661 insertions(+), 416 deletions(-) create mode 100644 is/nonNullable.js create mode 100644 is/nonNullable.md diff --git a/README.md b/README.md index 20fc58ec..9c1b319a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: any[]) => boolean +(xs?: any[] | undefined) => boolean ``` @@ -70,7 +70,10 @@ Checks if two arrays are not equal. ```typescript -(xs?: any[], ys?: any[]) => boolean +( + xs?: any[] | undefined, + ys?: any[] | undefined +) => boolean ``` @@ -94,7 +97,7 @@ Empty array. ```typescript -any[] +never[] ``` @@ -193,7 +196,7 @@ Flattens the nested arrays by a single level. ```typescript -(xs: any) => any[] +(xs: any) => never[] ``` @@ -371,7 +374,7 @@ Returns the second element or undefined when there are less than two elements in ```typescript -([, x]: [any, any]) => any +([, x]: any[]) => any ``` @@ -407,7 +410,7 @@ Shuffles the given array in random order with Math.random as the default. ```typescript -(xs: any, random?: () => number) => any[] +(xs: any, random?: (() => number) | undefined) => any[] ``` @@ -456,7 +459,7 @@ Sorts the given array without mutating it. ```typescript ( - f?: (a: any, b: any) => number + f?: ((a: any, b: any) => number) | undefined ) => (xs: any[]) => any[] ``` @@ -560,7 +563,7 @@ Runs the given tasks in a sequence. ```typescript -(tasks: (() => Promise)[]) => Promise +(tasks: (() => Promise)[]) => Promise ``` @@ -573,21 +576,21 @@ Runs the given tasks in a sequence. ```typescript ( - now: any + now: string | number | Date ) => ( { endedAt: aEnd, startedAt: aStart }: { - endedAt: any; - startedAt: any; + endedAt: string | number | Date; + startedAt: string | number | Date; }, { endedAt: bEnd, startedAt: bStart }: { - endedAt: any; - startedAt: any; + endedAt: string | number | Date; + startedAt: string | number | Date; } ) => number ``` @@ -599,7 +602,10 @@ Runs the given tasks in a sequence. ```typescript -(min: any, max: any) => (dateStringOrDate: any) => Date +( + min: number | Date, + max: number | Date +) => (dateStringOrDate: string | number | Date) => Date ``` @@ -609,7 +615,10 @@ Runs the given tasks in a sequence. ```typescript -(a: any, b: any) => number +( + a: string | number | Date, + b: string | number | Date +) => number ``` @@ -619,7 +628,10 @@ Runs the given tasks in a sequence. ```typescript -(from: any, to: any) => (date?: Date) => boolean +( + from: string | number | Date, + to: string | number | Date +) => (date?: Date) => boolean ``` @@ -635,11 +647,11 @@ Runs the given tasks in a sequence. now, timezoneOffset }: { - iso?: boolean; - local?: boolean; - now?: Date; - timezoneOffset?: number; -}) => (date: any) => any[] + iso?: boolean | undefined; + local?: boolean | undefined; + now?: Date | undefined; + timezoneOffset?: number | undefined; +}) => (date?: string | number | Date | undefined) => string[] ``` @@ -649,7 +661,22 @@ Runs the given tasks in a sequence. ```typescript -(leapYear: any) => number[] +( + leapYear: boolean +) => [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number +] ``` @@ -659,7 +686,7 @@ Runs the given tasks in a sequence. ```typescript -(year: any) => number +(year: number) => number ``` @@ -669,7 +696,7 @@ Runs the given tasks in a sequence. ```typescript -(monthIndex: any) => string +(monthIndex: number) => string ``` @@ -679,7 +706,10 @@ Runs the given tasks in a sequence. ```typescript -(source: any, showSeconds: any) => string +( + source: [number, number, number], + showSeconds: boolean +) => string ``` @@ -690,7 +720,7 @@ Runs the given tasks in a sequence. ```typescript ( - date: any, + date: string | number | Date, timezoneOffset?: number, local?: boolean ) => Date @@ -703,7 +733,7 @@ Runs the given tasks in a sequence. ```typescript -(sourceDate: any, timezoneOffset?: number) => string +(sourceDate: Date, timezoneOffset?: number) => string ``` @@ -714,7 +744,7 @@ Runs the given tasks in a sequence. ```typescript ( - sourceDate: any, + sourceDate: Date, showSeconds?: boolean, timezoneOffset?: number ) => string @@ -728,7 +758,7 @@ Runs the given tasks in a sequence. ```typescript ( - sourceDate: any, + sourceDate: Date, showDay?: boolean, timezoneOffset?: number ) => string @@ -741,7 +771,7 @@ Runs the given tasks in a sequence. ```typescript -(duration: any, showSeconds?: boolean) => string +(duration: number, showSeconds?: boolean) => string ``` @@ -752,7 +782,7 @@ Runs the given tasks in a sequence. ```typescript ( - sourceDate: any, + sourceDate: Date, showSeconds?: boolean, timezoneOffset?: number ) => string @@ -765,7 +795,7 @@ Runs the given tasks in a sequence. ```typescript -(days: any) => number +(days: number) => number ``` @@ -775,7 +805,7 @@ Runs the given tasks in a sequence. ```typescript -(hours: any) => number +(hours: number) => number ``` @@ -785,7 +815,7 @@ Runs the given tasks in a sequence. ```typescript -(minutes: any) => number +(minutes: number) => number ``` @@ -795,7 +825,7 @@ Runs the given tasks in a sequence. ```typescript -(seconds: any) => number +(seconds: number) => number ``` @@ -805,7 +835,7 @@ Runs the given tasks in a sequence. ```typescript -(...xs: any[]) => string +(...xs: string[]) => string ``` @@ -815,7 +845,7 @@ Runs the given tasks in a sequence. ```typescript -(year: any) => boolean +(year: number) => boolean ``` @@ -835,7 +865,7 @@ string[] ```typescript -(date: any) => Date +(date: number | Date) => Date ``` @@ -855,7 +885,7 @@ string[] ```typescript -(dateTimeString: any) => any +(dateTimeString: string) => string[] ``` @@ -866,7 +896,7 @@ string[] ```typescript ( - date: any, + date: string | number | Date, timezoneOffset?: number, local?: boolean ) => Date @@ -879,7 +909,10 @@ string[] ```typescript -(sourceDate: any, numberOfDays: any) => Date +( + sourceDate: string | number | Date, + numberOfDays: number +) => Date ``` @@ -889,7 +922,7 @@ string[] ```typescript -(date: any) => string +(date: Date) => string ``` @@ -899,7 +932,7 @@ string[] ```typescript -(xs: any) => any +(xs: (string | number | Date)[]) => Date[] ``` @@ -909,7 +942,7 @@ string[] ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` @@ -919,7 +952,7 @@ string[] ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` @@ -929,7 +962,7 @@ string[] ```typescript -(x: any) => any +(x: Date) => string ``` @@ -939,7 +972,7 @@ string[] ```typescript -(date: any) => string +(date: Date) => string ``` @@ -949,7 +982,7 @@ string[] ```typescript -(date: any, timezoneOffset?: number) => Date +(date: Date, timezoneOffset?: number) => Date ``` @@ -959,7 +992,7 @@ string[] ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` @@ -969,7 +1002,7 @@ string[] ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` @@ -979,7 +1012,7 @@ string[] ```typescript -(date: any) => boolean +(date?: any) => boolean ``` @@ -1008,7 +1041,18 @@ Computes a difference between two objects. ```typescript -(obj1: object, obj2: object) => object +( + obj1?: + | { + [index: string]: any; + } + | undefined, + obj2?: + | { + [index: string]: any; + } + | undefined +) => object ``` @@ -1023,42 +1067,30 @@ Provides a way to encode strings and bytes from and into Base64URL. ```typescript { - decode: ( - text: string, - context?: { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array) => string; - }; - } - ) => string; + decode: (text: string, context?: DecodeContext | undefined) => string; decodeBytes: ( text: string, - context?: { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array) => string; - }; - } + context?: + | { + atob: (byteString: string) => string; + TextDecoder: new (encoding: string) => { + decode: (input?: Uint8Array | undefined) => string; + }; + } + | undefined ) => number[]; encode: ( text: string, - context?: { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string) => Uint8Array; - }; - } - ) => string; - encodeBytes: ( - bytes: number[], - context?: { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string) => Uint8Array; - }; - } + context?: + | { + btoa: (byteString: string) => string; + TextEncoder: new () => { + encode: (input?: string | undefined) => Uint8Array; + }; + } + | undefined ) => string; + encodeBytes: (bytes: number[], context?: EncodeContext | undefined) => string; fromByteString: (byteString: string) => number[]; toByteString: (bytes: number[]) => string; } @@ -1251,7 +1283,7 @@ Checks if the given value is a byte. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean ``` @@ -1315,7 +1347,19 @@ Checks if given value is an integer. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean +``` + + +#### nonNullable + +Checks and asserts the given value is not a null or undefined. + +##### Type signature + + +```typescript +(val: T) => val is NonNullable ``` @@ -1327,7 +1371,7 @@ Checks if the given value is a number in a normal range [0, 1]. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean ``` @@ -1389,7 +1433,7 @@ Calculates the average of given array of numbers. ```typescript -(xs?: number[]) => number +(xs?: number[] | undefined) => number ``` @@ -1500,7 +1544,7 @@ Calculates the median of the values. If there is an even number of items, the av ```typescript -(xs?: number[]) => number +(xs?: number[] | undefined) => number | undefined ``` @@ -1574,7 +1618,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: object) => boolean +(xs?: object | undefined) => boolean ``` @@ -1588,7 +1632,12 @@ Applies the given parameters to the given dictionary of functions. ```typescript ( fs: ((...xs: any[]) => any)[] -) => (...xs: any[]) => object +) => ( + ...xs: any[] +) => { + [x: string]: any; + [x: number]: any; +} ``` @@ -1763,7 +1812,13 @@ Creates an object from array of key value pairs (entries). ```typescript -(keyValuePairs: [string, any][]) => object +{ + (entries: Iterable): { + [x: string]: T; + [x: number]: T; + }; + (entries: Iterable): any; +} ``` @@ -1787,7 +1842,7 @@ Checks if given key is present in the object. ```typescript -(key: string) => (xs?: any) => any +(key: string) => (xs?: any) => boolean ``` @@ -1865,7 +1920,12 @@ Merges two objects deeply. ```typescript -(a: object, b: object) => object +( + a: { + [index: string]: any; + }, + b: object +) => object ``` @@ -1897,7 +1957,7 @@ Checks if the given object is empty. ```typescript -(xs?: object) => boolean +(xs?: object | undefined) => boolean ``` @@ -1909,7 +1969,9 @@ Sorts the given object by a comparator. ```typescript -(f: any) => (xs: any) => object +( + f: (a: any, b: any) => number +) => (xs: object) => object ``` @@ -1923,7 +1985,12 @@ Parses a query string into an object. ```typescript -(xs?: string) => object +( + xs?: string +) => { + [x: string]: string | boolean; + [x: number]: string | boolean; +} ``` @@ -1947,7 +2014,7 @@ Serializes the given object into a query string. ```typescript -(xs?: {}) => string +(xs?: { [index: string]: any }) => string ``` @@ -1961,7 +2028,7 @@ Checks if the given range is empty. ```typescript -([min, max]: [any, any]) => boolean +([min, max]: [number, number]) => boolean ``` @@ -1982,7 +2049,10 @@ Checks if the given ranges are equal. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => boolean +( + [a, b]: [number, number], + [c, d]: [number, number] +) => boolean ``` @@ -1994,7 +2064,7 @@ Computes the signed length of the given range. ```typescript -([min, max]: [any, any]) => number +([min, max]: [number, number]) => number ``` @@ -2117,7 +2187,7 @@ Checks if the given string is present and is not empty or all whitespace. ```typescript -(x?: string) => boolean +(x?: string | undefined) => boolean ``` @@ -2177,7 +2247,10 @@ Calculates a cross product of the given vectors. Returns a scalar. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => number +( + [a, b]: [number, number], + [c, d]: [number, number] +) => number ``` @@ -2189,7 +2262,10 @@ Calculates a dot product of the given vectors. Returns a scalar. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => number +( + [a, b]: [number, number], + [c, d]: [number, number] +) => number ``` @@ -2278,7 +2354,7 @@ Normalizes the given vector. Returns [0, 0] vector for points. ```typescript -(vector: [number, number]) => number[] +(vector: [number, number]) => [number, number] ``` @@ -2452,10 +2528,10 @@ Tests if the current event seems like an intent to open a new tab. Useful for cl metaKey, shiftKey }: { - button: any; - ctrlKey: any; - metaKey: any; - shiftKey: any; + button?: number | undefined; + ctrlKey?: boolean | undefined; + metaKey?: boolean | undefined; + shiftKey?: boolean | undefined; }) => boolean ``` diff --git a/array/README.md b/array/README.md index b1bc4adb..2c9b0226 100644 --- a/array/README.md +++ b/array/README.md @@ -6,7 +6,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: any[]) => boolean +(xs?: any[] | undefined) => boolean ``` @@ -59,7 +59,10 @@ Checks if two arrays are not equal. ```typescript -(xs?: any[], ys?: any[]) => boolean +( + xs?: any[] | undefined, + ys?: any[] | undefined +) => boolean ``` @@ -83,7 +86,7 @@ Empty array. ```typescript -any[] +never[] ``` @@ -182,7 +185,7 @@ Flattens the nested arrays by a single level. ```typescript -(xs: any) => any[] +(xs: any) => never[] ``` @@ -360,7 +363,7 @@ Returns the second element or undefined when there are less than two elements in ```typescript -([, x]: [any, any]) => any +([, x]: any[]) => any ``` @@ -396,7 +399,7 @@ Shuffles the given array in random order with Math.random as the default. ```typescript -(xs: any, random?: () => number) => any[] +(xs: any, random?: (() => number) | undefined) => any[] ``` @@ -445,7 +448,7 @@ Sorts the given array without mutating it. ```typescript ( - f?: (a: any, b: any) => number + f?: ((a: any, b: any) => number) | undefined ) => (xs: any[]) => any[] ``` diff --git a/array/any.json b/array/any.json index df37c1f6..04a32fcb 100644 --- a/array/any.json +++ b/array/any.json @@ -1,7 +1,7 @@ { "name": "any", "description": "Checks if the given array is present and it is not empty (contains at least one element).", - "signature": "(xs?: any[]) => boolean", + "signature": "(xs?: any[] | undefined) => boolean", "examples": [ { "language": "javascript", diff --git a/array/any.md b/array/any.md index 097cfbe6..9544ee19 100644 --- a/array/any.md +++ b/array/any.md @@ -6,7 +6,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: any[]) => boolean +(xs?: any[] | undefined) => boolean ``` diff --git a/array/differs.js b/array/differs.js index af794c77..7ea5ae73 100644 --- a/array/differs.js +++ b/array/differs.js @@ -1,5 +1,9 @@ +import isNonNullable from "../is/nonNullable.js"; + export default (xs, ys) => Boolean(!xs && ys) || Boolean(!ys && xs) || + !isNonNullable(ys) || + !isNonNullable(xs) || xs.length !== ys.length || xs.some((x, index) => x !== ys[index]); diff --git a/array/differs.json b/array/differs.json index e97011db..4cf75396 100644 --- a/array/differs.json +++ b/array/differs.json @@ -1,7 +1,7 @@ { "name": "differs", "description": "Checks if two arrays are not equal.", - "signature": "(xs?: any[], ys?: any[]) => boolean", + "signature": "(\n xs?: any[] | undefined,\n ys?: any[] | undefined\n) => boolean", "examples": [ { "language": "javascript", diff --git a/array/differs.md b/array/differs.md index c41ba69d..6d81b32f 100644 --- a/array/differs.md +++ b/array/differs.md @@ -6,6 +6,9 @@ Checks if two arrays are not equal. ```typescript -(xs?: any[], ys?: any[]) => boolean +( + xs?: any[] | undefined, + ys?: any[] | undefined +) => boolean ``` diff --git a/array/empty.json b/array/empty.json index 8516b4bc..588272b3 100644 --- a/array/empty.json +++ b/array/empty.json @@ -1,7 +1,7 @@ { "name": "empty", "description": "Empty array.", - "signature": "any[]", + "signature": "never[]", "examples": [ { "language": "javascript", diff --git a/array/empty.md b/array/empty.md index 8348b892..7a166c53 100644 --- a/array/empty.md +++ b/array/empty.md @@ -6,7 +6,7 @@ Empty array. ```typescript -any[] +never[] ``` diff --git a/array/flatten.json b/array/flatten.json index bd8a2eb0..31bf7f39 100644 --- a/array/flatten.json +++ b/array/flatten.json @@ -1,7 +1,7 @@ { "name": "flatten", "description": "Flattens the nested arrays by a single level.", - "signature": "(xs: any) => any[]", + "signature": "(xs: any) => never[]", "examples": [ { "language": "javascript", diff --git a/array/flatten.md b/array/flatten.md index 42c98153..a95dceb6 100644 --- a/array/flatten.md +++ b/array/flatten.md @@ -6,6 +6,6 @@ Flattens the nested arrays by a single level. ```typescript -(xs: any) => any[] +(xs: any) => never[] ``` diff --git a/array/second.json b/array/second.json index 0b9838fe..e5fb2002 100644 --- a/array/second.json +++ b/array/second.json @@ -1,7 +1,7 @@ { "name": "second", "description": "Returns the second element or undefined when there are less than two elements in the given array.", - "signature": "([, x]: [any, any]) => any", + "signature": "([, x]: any[]) => any", "examples": [ { "language": "javascript", diff --git a/array/second.md b/array/second.md index 7917e7c8..d05ce695 100644 --- a/array/second.md +++ b/array/second.md @@ -6,6 +6,6 @@ Returns the second element or undefined when there are less than two elements in ```typescript -([, x]: [any, any]) => any +([, x]: any[]) => any ``` diff --git a/array/shuffle.json b/array/shuffle.json index 25c3db87..1d31c0e2 100644 --- a/array/shuffle.json +++ b/array/shuffle.json @@ -1,7 +1,7 @@ { "name": "shuffle", "description": "Shuffles the given array in random order with Math.random as the default.", - "signature": "(xs: any, random?: () => number) => any[]", + "signature": "(xs: any, random?: (() => number) | undefined) => any[]", "examples": [ { "language": "javascript", diff --git a/array/shuffle.md b/array/shuffle.md index 8bc533c5..937edefb 100644 --- a/array/shuffle.md +++ b/array/shuffle.md @@ -6,6 +6,6 @@ Shuffles the given array in random order with Math.random as the default. ```typescript -(xs: any, random?: () => number) => any[] +(xs: any, random?: (() => number) | undefined) => any[] ``` diff --git a/array/sort.json b/array/sort.json index fdd25ab7..a3fff1cc 100644 --- a/array/sort.json +++ b/array/sort.json @@ -1,7 +1,7 @@ { "name": "sort", "description": "Sorts the given array without mutating it.", - "signature": "(\n f?: (a: any, b: any) => number\n) => (xs: any[]) => any[]", + "signature": "(\n f?: ((a: any, b: any) => number) | undefined\n) => (xs: any[]) => any[]", "examples": [ { "language": "javascript", diff --git a/array/sort.md b/array/sort.md index f4d21c6a..1e225139 100644 --- a/array/sort.md +++ b/array/sort.md @@ -7,7 +7,7 @@ Sorts the given array without mutating it. ```typescript ( - f?: (a: any, b: any) => number + f?: ((a: any, b: any) => number) | undefined ) => (xs: any[]) => any[] ``` diff --git a/async/README.md b/async/README.md index e8a1ba64..0bd12192 100644 --- a/async/README.md +++ b/async/README.md @@ -33,6 +33,6 @@ Runs the given tasks in a sequence. ```typescript -(tasks: (() => Promise)[]) => Promise +(tasks: (() => Promise)[]) => Promise ``` diff --git a/async/sequence.json b/async/sequence.json index 77f0ed52..a278c3f1 100644 --- a/async/sequence.json +++ b/async/sequence.json @@ -1,7 +1,7 @@ { "name": "sequence", "description": "Runs the given tasks in a sequence.", - "signature": "(tasks: (() => Promise)[]) => Promise", + "signature": "(tasks: (() => Promise)[]) => Promise", "examples": [ { "language": "javascript", diff --git a/async/sequence.md b/async/sequence.md index 75661873..495eb7af 100644 --- a/async/sequence.md +++ b/async/sequence.md @@ -6,6 +6,6 @@ Runs the given tasks in a sequence. ```typescript -(tasks: (() => Promise)[]) => Promise +(tasks: (() => Promise)[]) => Promise ``` diff --git a/date/README.md b/date/README.md index d5cb0a97..23bdb7f9 100644 --- a/date/README.md +++ b/date/README.md @@ -5,21 +5,21 @@ ```typescript ( - now: any + now: string | number | Date ) => ( { endedAt: aEnd, startedAt: aStart }: { - endedAt: any; - startedAt: any; + endedAt: string | number | Date; + startedAt: string | number | Date; }, { endedAt: bEnd, startedAt: bStart }: { - endedAt: any; - startedAt: any; + endedAt: string | number | Date; + startedAt: string | number | Date; } ) => number ``` @@ -31,7 +31,10 @@ ```typescript -(min: any, max: any) => (dateStringOrDate: any) => Date +( + min: number | Date, + max: number | Date +) => (dateStringOrDate: string | number | Date) => Date ``` @@ -41,7 +44,10 @@ ```typescript -(a: any, b: any) => number +( + a: string | number | Date, + b: string | number | Date +) => number ``` @@ -51,7 +57,10 @@ ```typescript -(from: any, to: any) => (date?: Date) => boolean +( + from: string | number | Date, + to: string | number | Date +) => (date?: Date) => boolean ``` @@ -67,11 +76,11 @@ now, timezoneOffset }: { - iso?: boolean; - local?: boolean; - now?: Date; - timezoneOffset?: number; -}) => (date: any) => any[] + iso?: boolean | undefined; + local?: boolean | undefined; + now?: Date | undefined; + timezoneOffset?: number | undefined; +}) => (date?: string | number | Date | undefined) => string[] ``` @@ -81,7 +90,22 @@ ```typescript -(leapYear: any) => number[] +( + leapYear: boolean +) => [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number +] ``` @@ -91,7 +115,7 @@ ```typescript -(year: any) => number +(year: number) => number ``` @@ -101,7 +125,7 @@ ```typescript -(monthIndex: any) => string +(monthIndex: number) => string ``` @@ -111,7 +135,10 @@ ```typescript -(source: any, showSeconds: any) => string +( + source: [number, number, number], + showSeconds: boolean +) => string ``` @@ -122,7 +149,7 @@ ```typescript ( - date: any, + date: string | number | Date, timezoneOffset?: number, local?: boolean ) => Date @@ -135,7 +162,7 @@ ```typescript -(sourceDate: any, timezoneOffset?: number) => string +(sourceDate: Date, timezoneOffset?: number) => string ``` @@ -146,7 +173,7 @@ ```typescript ( - sourceDate: any, + sourceDate: Date, showSeconds?: boolean, timezoneOffset?: number ) => string @@ -160,7 +187,7 @@ ```typescript ( - sourceDate: any, + sourceDate: Date, showDay?: boolean, timezoneOffset?: number ) => string @@ -173,7 +200,7 @@ ```typescript -(duration: any, showSeconds?: boolean) => string +(duration: number, showSeconds?: boolean) => string ``` @@ -184,7 +211,7 @@ ```typescript ( - sourceDate: any, + sourceDate: Date, showSeconds?: boolean, timezoneOffset?: number ) => string @@ -197,7 +224,7 @@ ```typescript -(days: any) => number +(days: number) => number ``` @@ -207,7 +234,7 @@ ```typescript -(hours: any) => number +(hours: number) => number ``` @@ -217,7 +244,7 @@ ```typescript -(minutes: any) => number +(minutes: number) => number ``` @@ -227,7 +254,7 @@ ```typescript -(seconds: any) => number +(seconds: number) => number ``` @@ -237,7 +264,7 @@ ```typescript -(...xs: any[]) => string +(...xs: string[]) => string ``` @@ -247,7 +274,7 @@ ```typescript -(year: any) => boolean +(year: number) => boolean ``` @@ -267,7 +294,7 @@ string[] ```typescript -(date: any) => Date +(date: number | Date) => Date ``` @@ -287,7 +314,7 @@ string[] ```typescript -(dateTimeString: any) => any +(dateTimeString: string) => string[] ``` @@ -298,7 +325,7 @@ string[] ```typescript ( - date: any, + date: string | number | Date, timezoneOffset?: number, local?: boolean ) => Date @@ -311,7 +338,10 @@ string[] ```typescript -(sourceDate: any, numberOfDays: any) => Date +( + sourceDate: string | number | Date, + numberOfDays: number +) => Date ``` @@ -321,7 +351,7 @@ string[] ```typescript -(date: any) => string +(date: Date) => string ``` @@ -331,7 +361,7 @@ string[] ```typescript -(xs: any) => any +(xs: (string | number | Date)[]) => Date[] ``` @@ -341,7 +371,7 @@ string[] ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` @@ -351,7 +381,7 @@ string[] ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` @@ -361,7 +391,7 @@ string[] ```typescript -(x: any) => any +(x: Date) => string ``` @@ -371,7 +401,7 @@ string[] ```typescript -(date: any) => string +(date: Date) => string ``` @@ -381,7 +411,7 @@ string[] ```typescript -(date: any, timezoneOffset?: number) => Date +(date: Date, timezoneOffset?: number) => Date ``` @@ -391,7 +421,7 @@ string[] ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` @@ -401,7 +431,7 @@ string[] ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` @@ -411,6 +441,6 @@ string[] ```typescript -(date: any) => boolean +(date?: any) => boolean ``` diff --git a/date/byDateWithFallback.json b/date/byDateWithFallback.json index f611cceb..f045e83e 100644 --- a/date/byDateWithFallback.json +++ b/date/byDateWithFallback.json @@ -1,7 +1,7 @@ { "name": "byDateWithFallback", "description": "TODO: Fill short description here.", - "signature": "(\n now: any\n) => (\n {\n endedAt: aEnd,\n startedAt: aStart\n }: {\n endedAt: any;\n startedAt: any;\n },\n {\n endedAt: bEnd,\n startedAt: bStart\n }: {\n endedAt: any;\n startedAt: any;\n }\n) => number", + "signature": "(\n now: string | number | Date\n) => (\n {\n endedAt: aEnd,\n startedAt: aStart\n }: {\n endedAt: string | number | Date;\n startedAt: string | number | Date;\n },\n {\n endedAt: bEnd,\n startedAt: bStart\n }: {\n endedAt: string | number | Date;\n startedAt: string | number | Date;\n }\n) => number", "examples": [ { "language": "javascript", diff --git a/date/byDateWithFallback.md b/date/byDateWithFallback.md index 6d938882..df10b168 100644 --- a/date/byDateWithFallback.md +++ b/date/byDateWithFallback.md @@ -5,21 +5,21 @@ ```typescript ( - now: any + now: string | number | Date ) => ( { endedAt: aEnd, startedAt: aStart }: { - endedAt: any; - startedAt: any; + endedAt: string | number | Date; + startedAt: string | number | Date; }, { endedAt: bEnd, startedAt: bStart }: { - endedAt: any; - startedAt: any; + endedAt: string | number | Date; + startedAt: string | number | Date; } ) => number ``` diff --git a/date/clamp.json b/date/clamp.json index 53da8bbf..93413be6 100644 --- a/date/clamp.json +++ b/date/clamp.json @@ -1,7 +1,7 @@ { "name": "clamp", "description": "TODO: Fill short description here.", - "signature": "(min: any, max: any) => (dateStringOrDate: any) => Date", + "signature": "(\n min: number | Date,\n max: number | Date\n) => (dateStringOrDate: string | number | Date) => Date", "examples": [ { "language": "javascript", diff --git a/date/clamp.md b/date/clamp.md index 4e872f0d..012878c8 100644 --- a/date/clamp.md +++ b/date/clamp.md @@ -4,6 +4,9 @@ ```typescript -(min: any, max: any) => (dateStringOrDate: any) => Date +( + min: number | Date, + max: number | Date +) => (dateStringOrDate: string | number | Date) => Date ``` diff --git a/date/dateDiff.json b/date/dateDiff.json index 913e706c..a6d66fda 100644 --- a/date/dateDiff.json +++ b/date/dateDiff.json @@ -1,7 +1,7 @@ { "name": "dateDiff", "description": "TODO: Fill short description here.", - "signature": "(a: any, b: any) => number", + "signature": "(\n a: string | number | Date,\n b: string | number | Date\n) => number", "examples": [ { "language": "javascript", diff --git a/date/dateDiff.md b/date/dateDiff.md index cba3b9dd..ebc6761f 100644 --- a/date/dateDiff.md +++ b/date/dateDiff.md @@ -4,6 +4,9 @@ ```typescript -(a: any, b: any) => number +( + a: string | number | Date, + b: string | number | Date +) => number ``` diff --git a/date/dateInRange.json b/date/dateInRange.json index ef4edab0..db7e8e6e 100644 --- a/date/dateInRange.json +++ b/date/dateInRange.json @@ -1,7 +1,7 @@ { "name": "dateInRange", "description": "TODO: Fill short description here.", - "signature": "(from: any, to: any) => (date?: Date) => boolean", + "signature": "(\n from: string | number | Date,\n to: string | number | Date\n) => (date?: Date) => boolean", "examples": [ { "language": "javascript", diff --git a/date/dateInRange.md b/date/dateInRange.md index 115a6199..067db71b 100644 --- a/date/dateInRange.md +++ b/date/dateInRange.md @@ -4,6 +4,9 @@ ```typescript -(from: any, to: any) => (date?: Date) => boolean +( + from: string | number | Date, + to: string | number | Date +) => (date?: Date) => boolean ``` diff --git a/date/dayRange.json b/date/dayRange.json index 9d5d6503..32ab999e 100644 --- a/date/dayRange.json +++ b/date/dayRange.json @@ -1,7 +1,7 @@ { "name": "dayRange", "description": "TODO: Fill short description here.", - "signature": "({\n iso,\n local,\n now,\n timezoneOffset\n}: {\n iso?: boolean;\n local?: boolean;\n now?: Date;\n timezoneOffset?: number;\n}) => (date: any) => any[]", + "signature": "({\n iso,\n local,\n now,\n timezoneOffset\n}: {\n iso?: boolean | undefined;\n local?: boolean | undefined;\n now?: Date | undefined;\n timezoneOffset?: number | undefined;\n}) => (date?: string | number | Date | undefined) => string[]", "examples": [ { "language": "javascript", diff --git a/date/dayRange.md b/date/dayRange.md index d6729e2c..ac3c7732 100644 --- a/date/dayRange.md +++ b/date/dayRange.md @@ -10,10 +10,10 @@ now, timezoneOffset }: { - iso?: boolean; - local?: boolean; - now?: Date; - timezoneOffset?: number; -}) => (date: any) => any[] + iso?: boolean | undefined; + local?: boolean | undefined; + now?: Date | undefined; + timezoneOffset?: number | undefined; +}) => (date?: string | number | Date | undefined) => string[] ``` diff --git a/date/daysInMonths.json b/date/daysInMonths.json index 9f0cfdad..83aeb8f5 100644 --- a/date/daysInMonths.json +++ b/date/daysInMonths.json @@ -1,7 +1,7 @@ { "name": "daysInMonths", "description": "TODO: Fill short description here.", - "signature": "(leapYear: any) => number[]", + "signature": "(\n leapYear: boolean\n) => [\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number,\n number\n]", "examples": [ { "language": "javascript", diff --git a/date/daysInMonths.md b/date/daysInMonths.md index b5b51fee..620aa894 100644 --- a/date/daysInMonths.md +++ b/date/daysInMonths.md @@ -4,6 +4,21 @@ ```typescript -(leapYear: any) => number[] +( + leapYear: boolean +) => [ + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number, + number +] ``` diff --git a/date/daysInYear.json b/date/daysInYear.json index 601818cc..0d97c09a 100644 --- a/date/daysInYear.json +++ b/date/daysInYear.json @@ -1,7 +1,7 @@ { "name": "daysInYear", "description": "TODO: Fill short description here.", - "signature": "(year: any) => number", + "signature": "(year: number) => number", "examples": [ { "language": "javascript", diff --git a/date/daysInYear.md b/date/daysInYear.md index 03de6148..a6f167df 100644 --- a/date/daysInYear.md +++ b/date/daysInYear.md @@ -4,6 +4,6 @@ ```typescript -(year: any) => number +(year: number) => number ``` diff --git a/date/displayMonth.json b/date/displayMonth.json index f033d622..95707c1c 100644 --- a/date/displayMonth.json +++ b/date/displayMonth.json @@ -1,7 +1,7 @@ { "name": "displayMonth", "description": "TODO: Fill short description here.", - "signature": "(monthIndex: any) => string", + "signature": "(monthIndex: number) => string", "examples": [ { "language": "javascript", diff --git a/date/displayMonth.md b/date/displayMonth.md index 23bb48d2..71e29976 100644 --- a/date/displayMonth.md +++ b/date/displayMonth.md @@ -4,6 +4,6 @@ ```typescript -(monthIndex: any) => string +(monthIndex: number) => string ``` diff --git a/date/displayTime.json b/date/displayTime.json index c73d4c32..837310bf 100644 --- a/date/displayTime.json +++ b/date/displayTime.json @@ -1,7 +1,7 @@ { "name": "displayTime", "description": "TODO: Fill short description here.", - "signature": "(source: any, showSeconds: any) => string", + "signature": "(\n source: [number, number, number],\n showSeconds: boolean\n) => string", "examples": [ { "language": "javascript", diff --git a/date/displayTime.md b/date/displayTime.md index e02d2a67..3ae4381c 100644 --- a/date/displayTime.md +++ b/date/displayTime.md @@ -4,6 +4,9 @@ ```typescript -(source: any, showSeconds: any) => string +( + source: [number, number, number], + showSeconds: boolean +) => string ``` diff --git a/date/endOfDay.json b/date/endOfDay.json index 47e30618..0458a645 100644 --- a/date/endOfDay.json +++ b/date/endOfDay.json @@ -1,7 +1,7 @@ { "name": "endOfDay", "description": "TODO: Fill short description here.", - "signature": "(\n date: any,\n timezoneOffset?: number,\n local?: boolean\n) => Date", + "signature": "(\n date: string | number | Date,\n timezoneOffset?: number,\n local?: boolean\n) => Date", "examples": [ { "language": "javascript", diff --git a/date/endOfDay.md b/date/endOfDay.md index 15f9a5fe..8ba2cda9 100644 --- a/date/endOfDay.md +++ b/date/endOfDay.md @@ -5,7 +5,7 @@ ```typescript ( - date: any, + date: string | number | Date, timezoneOffset?: number, local?: boolean ) => Date diff --git a/date/formatDate.json b/date/formatDate.json index 2ba85e7e..e15a49e6 100644 --- a/date/formatDate.json +++ b/date/formatDate.json @@ -1,7 +1,7 @@ { "name": "formatDate", "description": "TODO: Fill short description here.", - "signature": "(sourceDate: any, timezoneOffset?: number) => string", + "signature": "(sourceDate: Date, timezoneOffset?: number) => string", "examples": [ { "language": "javascript", diff --git a/date/formatDate.md b/date/formatDate.md index 00d03f08..3227aad4 100644 --- a/date/formatDate.md +++ b/date/formatDate.md @@ -4,6 +4,6 @@ ```typescript -(sourceDate: any, timezoneOffset?: number) => string +(sourceDate: Date, timezoneOffset?: number) => string ``` diff --git a/date/formatDateTime.json b/date/formatDateTime.json index 9c6bde48..69a087ec 100644 --- a/date/formatDateTime.json +++ b/date/formatDateTime.json @@ -1,7 +1,7 @@ { "name": "formatDateTime", "description": "TODO: Fill short description here.", - "signature": "(\n sourceDate: any,\n showSeconds?: boolean,\n timezoneOffset?: number\n) => string", + "signature": "(\n sourceDate: Date,\n showSeconds?: boolean,\n timezoneOffset?: number\n) => string", "examples": [ { "language": "javascript", diff --git a/date/formatDateTime.md b/date/formatDateTime.md index 572aeb24..69eae52e 100644 --- a/date/formatDateTime.md +++ b/date/formatDateTime.md @@ -5,7 +5,7 @@ ```typescript ( - sourceDate: any, + sourceDate: Date, showSeconds?: boolean, timezoneOffset?: number ) => string diff --git a/date/formatDisplayDate.json b/date/formatDisplayDate.json index 3e1f8d4c..145194da 100644 --- a/date/formatDisplayDate.json +++ b/date/formatDisplayDate.json @@ -1,7 +1,7 @@ { "name": "formatDisplayDate", "description": "TODO: Fill short description here.", - "signature": "(\n sourceDate: any,\n showDay?: boolean,\n timezoneOffset?: number\n) => string", + "signature": "(\n sourceDate: Date,\n showDay?: boolean,\n timezoneOffset?: number\n) => string", "examples": [ { "language": "javascript", diff --git a/date/formatDisplayDate.md b/date/formatDisplayDate.md index 52deddcd..dd9dd814 100644 --- a/date/formatDisplayDate.md +++ b/date/formatDisplayDate.md @@ -5,7 +5,7 @@ ```typescript ( - sourceDate: any, + sourceDate: Date, showDay?: boolean, timezoneOffset?: number ) => string diff --git a/date/formatDuration.json b/date/formatDuration.json index 108d59f6..18c116f0 100644 --- a/date/formatDuration.json +++ b/date/formatDuration.json @@ -1,7 +1,7 @@ { "name": "formatDuration", "description": "TODO: Fill short description here.", - "signature": "(duration: any, showSeconds?: boolean) => string", + "signature": "(duration: number, showSeconds?: boolean) => string", "examples": [ { "language": "javascript", diff --git a/date/formatDuration.md b/date/formatDuration.md index 3dead43e..5a59ebe8 100644 --- a/date/formatDuration.md +++ b/date/formatDuration.md @@ -4,6 +4,6 @@ ```typescript -(duration: any, showSeconds?: boolean) => string +(duration: number, showSeconds?: boolean) => string ``` diff --git a/date/formatTime.js b/date/formatTime.js index 6c01768f..1cb569ae 100644 --- a/date/formatTime.js +++ b/date/formatTime.js @@ -4,11 +4,11 @@ import displayTime from "./displayTime.js"; export default (sourceDate, showSeconds = false, timezoneOffset = 0) => { const localDate = toLocalDateTime(sourceDate, timezoneOffset); - const source = [ + const [hours, minutes, seconds] = [ localDate.getUTCHours(), localDate.getUTCMinutes(), localDate.getUTCSeconds() ]; - return displayTime(source, showSeconds); + return displayTime([hours, minutes, seconds], showSeconds); }; diff --git a/date/formatTime.json b/date/formatTime.json index a2391390..e918ede6 100644 --- a/date/formatTime.json +++ b/date/formatTime.json @@ -1,7 +1,7 @@ { "name": "formatTime", "description": "TODO: Fill short description here.", - "signature": "(\n sourceDate: any,\n showSeconds?: boolean,\n timezoneOffset?: number\n) => string", + "signature": "(\n sourceDate: Date,\n showSeconds?: boolean,\n timezoneOffset?: number\n) => string", "examples": [ { "language": "javascript", diff --git a/date/formatTime.md b/date/formatTime.md index e496b1e7..92ee6ff9 100644 --- a/date/formatTime.md +++ b/date/formatTime.md @@ -5,7 +5,7 @@ ```typescript ( - sourceDate: any, + sourceDate: Date, showSeconds?: boolean, timezoneOffset?: number ) => string diff --git a/date/fromDays.json b/date/fromDays.json index de6eab7b..22b866f5 100644 --- a/date/fromDays.json +++ b/date/fromDays.json @@ -1,7 +1,7 @@ { "name": "fromDays", "description": "TODO: Fill short description here.", - "signature": "(days: any) => number", + "signature": "(days: number) => number", "examples": [ { "language": "javascript", diff --git a/date/fromDays.md b/date/fromDays.md index 588ae71c..cc963c98 100644 --- a/date/fromDays.md +++ b/date/fromDays.md @@ -4,6 +4,6 @@ ```typescript -(days: any) => number +(days: number) => number ``` diff --git a/date/fromHours.json b/date/fromHours.json index 65034044..c04a6a8c 100644 --- a/date/fromHours.json +++ b/date/fromHours.json @@ -1,7 +1,7 @@ { "name": "fromHours", "description": "TODO: Fill short description here.", - "signature": "(hours: any) => number", + "signature": "(hours: number) => number", "examples": [ { "language": "javascript", diff --git a/date/fromMinutes.json b/date/fromMinutes.json index 986a93ee..ac3e6e8c 100644 --- a/date/fromMinutes.json +++ b/date/fromMinutes.json @@ -1,7 +1,7 @@ { "name": "fromMinutes", "description": "TODO: Fill short description here.", - "signature": "(minutes: any) => number", + "signature": "(minutes: number) => number", "examples": [ { "language": "javascript", diff --git a/date/fromMinutes.md b/date/fromMinutes.md index 41238e7e..c095e696 100644 --- a/date/fromMinutes.md +++ b/date/fromMinutes.md @@ -4,6 +4,6 @@ ```typescript -(minutes: any) => number +(minutes: number) => number ``` diff --git a/date/fromSeconds.json b/date/fromSeconds.json index ef4d3ada..12343565 100644 --- a/date/fromSeconds.json +++ b/date/fromSeconds.json @@ -1,7 +1,7 @@ { "name": "fromSeconds", "description": "TODO: Fill short description here.", - "signature": "(seconds: any) => number", + "signature": "(seconds: number) => number", "examples": [ { "language": "javascript", diff --git a/date/fromSeconds.md b/date/fromSeconds.md index 2f674d1d..1da52d80 100644 --- a/date/fromSeconds.md +++ b/date/fromSeconds.md @@ -4,6 +4,6 @@ ```typescript -(seconds: any) => number +(seconds: number) => number ``` diff --git a/date/joinDateTime.json b/date/joinDateTime.json index e0ab224e..1c4641a3 100644 --- a/date/joinDateTime.json +++ b/date/joinDateTime.json @@ -1,7 +1,7 @@ { "name": "joinDateTime", "description": "TODO: Fill short description here.", - "signature": "(...xs: any[]) => string", + "signature": "(...xs: string[]) => string", "examples": [ { "language": "javascript", diff --git a/date/joinDateTime.md b/date/joinDateTime.md index 4075dc00..de8bd7a6 100644 --- a/date/joinDateTime.md +++ b/date/joinDateTime.md @@ -4,6 +4,6 @@ ```typescript -(...xs: any[]) => string +(...xs: string[]) => string ``` diff --git a/date/leapYear.json b/date/leapYear.json index 72cbaea0..55c89670 100644 --- a/date/leapYear.json +++ b/date/leapYear.json @@ -1,7 +1,7 @@ { "name": "leapYear", "description": "TODO: Fill short description here.", - "signature": "(year: any) => boolean", + "signature": "(year: number) => boolean", "examples": [ { "language": "javascript", diff --git a/date/leapYear.md b/date/leapYear.md index d36cc719..6c5b9c9c 100644 --- a/date/leapYear.md +++ b/date/leapYear.md @@ -4,6 +4,6 @@ ```typescript -(year: any) => boolean +(year: number) => boolean ``` diff --git a/date/offsetByBit.js b/date/offsetByBit.js index 7581ee97..07a6a757 100644 --- a/date/offsetByBit.js +++ b/date/offsetByBit.js @@ -2,4 +2,4 @@ import fromSeconds from "./fromSeconds.js"; const SECOND = fromSeconds(1); -export default date => new Date(date - SECOND); +export default date => new Date(date.valueOf() - SECOND); diff --git a/date/offsetByBit.json b/date/offsetByBit.json index b88fa0ba..5fd24cad 100644 --- a/date/offsetByBit.json +++ b/date/offsetByBit.json @@ -1,7 +1,7 @@ { "name": "offsetByBit", "description": "TODO: Fill short description here.", - "signature": "(date: any) => Date", + "signature": "(date: number | Date) => Date", "examples": [ { "language": "javascript", diff --git a/date/offsetByBit.md b/date/offsetByBit.md index 0ad50b67..a06f446d 100644 --- a/date/offsetByBit.md +++ b/date/offsetByBit.md @@ -4,6 +4,6 @@ ```typescript -(date: any) => Date +(date: number | Date) => Date ``` diff --git a/date/splitDateTime.json b/date/splitDateTime.json index ae00daa1..8ac0b4f2 100644 --- a/date/splitDateTime.json +++ b/date/splitDateTime.json @@ -1,7 +1,7 @@ { "name": "splitDateTime", "description": "TODO: Fill short description here.", - "signature": "(dateTimeString: any) => any", + "signature": "(dateTimeString: string) => string[]", "examples": [ { "language": "javascript", diff --git a/date/splitDateTime.md b/date/splitDateTime.md index 8fc84f93..c3d271cf 100644 --- a/date/splitDateTime.md +++ b/date/splitDateTime.md @@ -4,6 +4,6 @@ ```typescript -(dateTimeString: any) => any +(dateTimeString: string) => string[] ``` diff --git a/date/startOfDay.json b/date/startOfDay.json index 51703226..d37e783c 100644 --- a/date/startOfDay.json +++ b/date/startOfDay.json @@ -1,7 +1,7 @@ { "name": "startOfDay", "description": "TODO: Fill short description here.", - "signature": "(\n date: any,\n timezoneOffset?: number,\n local?: boolean\n) => Date", + "signature": "(\n date: string | number | Date,\n timezoneOffset?: number,\n local?: boolean\n) => Date", "examples": [ { "language": "javascript", diff --git a/date/startOfDay.md b/date/startOfDay.md index 22e28d4a..43f4f558 100644 --- a/date/startOfDay.md +++ b/date/startOfDay.md @@ -5,7 +5,7 @@ ```typescript ( - date: any, + date: string | number | Date, timezoneOffset?: number, local?: boolean ) => Date diff --git a/date/subtractDays.json b/date/subtractDays.json index 51bec5c9..fb15ab8f 100644 --- a/date/subtractDays.json +++ b/date/subtractDays.json @@ -1,7 +1,7 @@ { "name": "subtractDays", "description": "TODO: Fill short description here.", - "signature": "(sourceDate: any, numberOfDays: any) => Date", + "signature": "(\n sourceDate: string | number | Date,\n numberOfDays: number\n) => Date", "examples": [ { "language": "javascript", diff --git a/date/subtractDays.md b/date/subtractDays.md index 3e2d05d0..51f6ab60 100644 --- a/date/subtractDays.md +++ b/date/subtractDays.md @@ -4,6 +4,9 @@ ```typescript -(sourceDate: any, numberOfDays: any) => Date +( + sourceDate: string | number | Date, + numberOfDays: number +) => Date ``` diff --git a/date/toDate.json b/date/toDate.json index 6b36007d..59a70d33 100644 --- a/date/toDate.json +++ b/date/toDate.json @@ -1,7 +1,7 @@ { "name": "toDate", "description": "TODO: Fill short description here.", - "signature": "(date: any) => string", + "signature": "(date: Date) => string", "examples": [ { "language": "javascript", diff --git a/date/toDate.md b/date/toDate.md index 64346443..f0d05cc7 100644 --- a/date/toDate.md +++ b/date/toDate.md @@ -4,6 +4,6 @@ ```typescript -(date: any) => string +(date: Date) => string ``` diff --git a/date/toDates.json b/date/toDates.json index 1e8459a0..d2382d71 100644 --- a/date/toDates.json +++ b/date/toDates.json @@ -1,7 +1,7 @@ { "name": "toDates", "description": "TODO: Fill short description here.", - "signature": "(xs: any) => any", + "signature": "(xs: (string | number | Date)[]) => Date[]", "examples": [ { "language": "javascript", diff --git a/date/toDates.md b/date/toDates.md index 225de78f..2464a4b6 100644 --- a/date/toDates.md +++ b/date/toDates.md @@ -4,6 +4,6 @@ ```typescript -(xs: any) => any +(xs: (string | number | Date)[]) => Date[] ``` diff --git a/date/toDays.json b/date/toDays.json index 57e70b9e..f8fb1d70 100644 --- a/date/toDays.json +++ b/date/toDays.json @@ -1,7 +1,7 @@ { "name": "toDays", "description": "TODO: Fill short description here.", - "signature": "(milliseconds: any) => number", + "signature": "(milliseconds: number) => number", "examples": [ { "language": "javascript", diff --git a/date/toDays.md b/date/toDays.md index b748b5f9..984bdaa4 100644 --- a/date/toDays.md +++ b/date/toDays.md @@ -4,6 +4,6 @@ ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` diff --git a/date/toHours.json b/date/toHours.json index 7d2eb044..18ccfee2 100644 --- a/date/toHours.json +++ b/date/toHours.json @@ -1,7 +1,7 @@ { "name": "toHours", "description": "TODO: Fill short description here.", - "signature": "(milliseconds: any) => number", + "signature": "(milliseconds: number) => number", "examples": [ { "language": "javascript", diff --git a/date/toHours.md b/date/toHours.md index 1ed852a6..91bbc2b2 100644 --- a/date/toHours.md +++ b/date/toHours.md @@ -4,6 +4,6 @@ ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` diff --git a/date/toISO.json b/date/toISO.json index d2792866..231ca90f 100644 --- a/date/toISO.json +++ b/date/toISO.json @@ -1,7 +1,7 @@ { "name": "toISO", "description": "TODO: Fill short description here.", - "signature": "(x: any) => any", + "signature": "(x: Date) => string", "examples": [ { "language": "javascript", diff --git a/date/toISO.md b/date/toISO.md index 12d68ca9..49e8839c 100644 --- a/date/toISO.md +++ b/date/toISO.md @@ -4,6 +4,6 @@ ```typescript -(x: any) => any +(x: Date) => string ``` diff --git a/date/toISOFromLocalDateTime.json b/date/toISOFromLocalDateTime.json index 671c7b32..b06b6374 100644 --- a/date/toISOFromLocalDateTime.json +++ b/date/toISOFromLocalDateTime.json @@ -1,7 +1,7 @@ { "name": "toISOFromLocalDateTime", "description": "TODO: Fill short description here.", - "signature": "(date: any) => string", + "signature": "(date: Date) => string", "examples": [ { "language": "javascript", diff --git a/date/toISOFromLocalDateTime.md b/date/toISOFromLocalDateTime.md index 20392bf2..7310db3c 100644 --- a/date/toISOFromLocalDateTime.md +++ b/date/toISOFromLocalDateTime.md @@ -4,6 +4,6 @@ ```typescript -(date: any) => string +(date: Date) => string ``` diff --git a/date/toLocalDateTime.json b/date/toLocalDateTime.json index a3f43527..a935be42 100644 --- a/date/toLocalDateTime.json +++ b/date/toLocalDateTime.json @@ -1,7 +1,7 @@ { "name": "toLocalDateTime", "description": "TODO: Fill short description here.", - "signature": "(date: any, timezoneOffset?: number) => Date", + "signature": "(date: Date, timezoneOffset?: number) => Date", "examples": [ { "language": "javascript", diff --git a/date/toLocalDateTime.md b/date/toLocalDateTime.md index a9c058c5..679d4a20 100644 --- a/date/toLocalDateTime.md +++ b/date/toLocalDateTime.md @@ -4,6 +4,6 @@ ```typescript -(date: any, timezoneOffset?: number) => Date +(date: Date, timezoneOffset?: number) => Date ``` diff --git a/date/toMinutes.json b/date/toMinutes.json index a7ecfa08..1bfb4fae 100644 --- a/date/toMinutes.json +++ b/date/toMinutes.json @@ -1,7 +1,7 @@ { "name": "toMinutes", "description": "TODO: Fill short description here.", - "signature": "(milliseconds: any) => number", + "signature": "(milliseconds: number) => number", "examples": [ { "language": "javascript", diff --git a/date/toMinutes.md b/date/toMinutes.md index 74e2fc17..405f5c85 100644 --- a/date/toMinutes.md +++ b/date/toMinutes.md @@ -4,6 +4,6 @@ ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` diff --git a/date/toSeconds.json b/date/toSeconds.json index bfd03aab..db6b3fc5 100644 --- a/date/toSeconds.json +++ b/date/toSeconds.json @@ -1,7 +1,7 @@ { "name": "toSeconds", "description": "TODO: Fill short description here.", - "signature": "(milliseconds: any) => number", + "signature": "(milliseconds: number) => number", "examples": [ { "language": "javascript", diff --git a/date/toSeconds.md b/date/toSeconds.md index e1adfbcf..003f9fd7 100644 --- a/date/toSeconds.md +++ b/date/toSeconds.md @@ -4,6 +4,6 @@ ```typescript -(milliseconds: any) => number +(milliseconds: number) => number ``` diff --git a/date/valid.js b/date/valid.js index 83119e28..1e1ee749 100644 --- a/date/valid.js +++ b/date/valid.js @@ -1 +1 @@ -export default date => date && date instanceof Date; +export default date => (date ? date instanceof Date : false); diff --git a/date/valid.json b/date/valid.json index f7e19c9e..314fe758 100644 --- a/date/valid.json +++ b/date/valid.json @@ -1,7 +1,7 @@ { "name": "valid", "description": "TODO: Fill short description here.", - "signature": "(date: any) => boolean", + "signature": "(date?: any) => boolean", "examples": [ { "language": "javascript", diff --git a/date/valid.md b/date/valid.md index e2bfbf14..014ebdd5 100644 --- a/date/valid.md +++ b/date/valid.md @@ -4,6 +4,6 @@ ```typescript -(date: any) => boolean +(date?: any) => boolean ``` diff --git a/debug/README.md b/debug/README.md index aba589e5..95ac43a7 100644 --- a/debug/README.md +++ b/debug/README.md @@ -21,6 +21,17 @@ Computes a difference between two objects. ```typescript -(obj1: object, obj2: object) => object +( + obj1?: + | { + [index: string]: any; + } + | undefined, + obj2?: + | { + [index: string]: any; + } + | undefined +) => object ``` diff --git a/debug/diff.js b/debug/diff.js index a87f7a81..cbd5d75e 100644 --- a/debug/diff.js +++ b/debug/diff.js @@ -41,7 +41,7 @@ const compareValues = (value1, value2) => { }; const diff = (obj1, obj2) => { - if (isValue(obj1) || isValue(obj2)) { + if (!obj1 || !obj2 || isValue(obj1) || isValue(obj2)) { const comparisonResult = compareValues(obj1, obj2); return comparisonResult !== VALUE_UNCHANGED @@ -49,31 +49,31 @@ const diff = (obj1, obj2) => { type: comparisonResult, data: [obj1, obj2] } - : null; + : {}; } const result = {}; for (const key in obj1) { - if (isFunction(obj1[key])) { - continue; - } - - let value2 = undefined; + const value1 = obj1[key]; - if (isDefined(obj2[key])) { - value2 = obj2[key]; + if (isFunction(value1)) { + continue; } - result[key] = diff(obj1[key], value2); + const value2 = obj2[key]; + result[key] = diff(value1, value2); } for (const key in obj2) { - if (isFunction(obj2[key]) || isDefined(result[key])) { + const value2 = obj2[key]; + const existingValue = result[key]; + + if (isFunction(value2) || isDefined(existingValue)) { continue; } - result[key] = diff(undefined, obj2[key]); + result[key] = diff(undefined, value2); } return filter( diff --git a/debug/diff.json b/debug/diff.json index 471e1e00..7be669fa 100644 --- a/debug/diff.json +++ b/debug/diff.json @@ -1,7 +1,7 @@ { "name": "diff", "description": "Computes a difference between two objects.", - "signature": "(obj1: object, obj2: object) => object", + "signature": "(\n obj1?:\n | {\n [index: string]: any;\n }\n | undefined,\n obj2?:\n | {\n [index: string]: any;\n }\n | undefined\n) => object", "examples": [ { "language": "javascript", diff --git a/debug/diff.md b/debug/diff.md index ea57e1b3..e07498b6 100644 --- a/debug/diff.md +++ b/debug/diff.md @@ -6,6 +6,17 @@ Computes a difference between two objects. ```typescript -(obj1: object, obj2: object) => object +( + obj1?: + | { + [index: string]: any; + } + | undefined, + obj2?: + | { + [index: string]: any; + } + | undefined +) => object ``` diff --git a/encoding/README.md b/encoding/README.md index 08026f4b..854c6677 100644 --- a/encoding/README.md +++ b/encoding/README.md @@ -7,42 +7,30 @@ Provides a way to encode strings and bytes from and into Base64URL. ```typescript { - decode: ( - text: string, - context?: { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array) => string; - }; - } - ) => string; + decode: (text: string, context?: DecodeContext | undefined) => string; decodeBytes: ( text: string, - context?: { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array) => string; - }; - } + context?: + | { + atob: (byteString: string) => string; + TextDecoder: new (encoding: string) => { + decode: (input?: Uint8Array | undefined) => string; + }; + } + | undefined ) => number[]; encode: ( text: string, - context?: { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string) => Uint8Array; - }; - } - ) => string; - encodeBytes: ( - bytes: number[], - context?: { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string) => Uint8Array; - }; - } + context?: + | { + btoa: (byteString: string) => string; + TextEncoder: new () => { + encode: (input?: string | undefined) => Uint8Array; + }; + } + | undefined ) => string; + encodeBytes: (bytes: number[], context?: EncodeContext | undefined) => string; fromByteString: (byteString: string) => number[]; toByteString: (bytes: number[]) => string; } diff --git a/encoding/base64url.js b/encoding/base64url.js index c7e9165e..6c6d1a70 100644 --- a/encoding/base64url.js +++ b/encoding/base64url.js @@ -5,7 +5,7 @@ export const toByteString = bytes => bytes.map(_ => String.fromCharCode(_)).join(""); export const fromByteString = byteString => - [...byteString].map(_ => _.codePointAt(0)); + [...byteString].map(_ => _.codePointAt(0) || 0); const ENCODING = "utf-8"; diff --git a/encoding/base64url.json b/encoding/base64url.json index 78711552..d692d5f9 100644 --- a/encoding/base64url.json +++ b/encoding/base64url.json @@ -1,7 +1,7 @@ { "name": "base64url", "description": "Provides a way to encode strings and bytes from and into Base64URL.", - "signature": "{\n decode: (\n text: string,\n context?: {\n atob: (byteString: string) => string;\n TextDecoder: new (encoding: string) => {\n decode: (input?: Uint8Array) => string;\n };\n }\n ) => string;\n decodeBytes: (\n text: string,\n context?: {\n atob: (byteString: string) => string;\n TextDecoder: new (encoding: string) => {\n decode: (input?: Uint8Array) => string;\n };\n }\n ) => number[];\n encode: (\n text: string,\n context?: {\n btoa: (byteString: string) => string;\n TextEncoder: new () => {\n encode: (input?: string) => Uint8Array;\n };\n }\n ) => string;\n encodeBytes: (\n bytes: number[],\n context?: {\n btoa: (byteString: string) => string;\n TextEncoder: new () => {\n encode: (input?: string) => Uint8Array;\n };\n }\n ) => string;\n fromByteString: (byteString: string) => number[];\n toByteString: (bytes: number[]) => string;\n}", + "signature": "{\n decode: (text: string, context?: DecodeContext | undefined) => string;\n decodeBytes: (\n text: string,\n context?:\n | {\n atob: (byteString: string) => string;\n TextDecoder: new (encoding: string) => {\n decode: (input?: Uint8Array | undefined) => string;\n };\n }\n | undefined\n ) => number[];\n encode: (\n text: string,\n context?:\n | {\n btoa: (byteString: string) => string;\n TextEncoder: new () => {\n encode: (input?: string | undefined) => Uint8Array;\n };\n }\n | undefined\n ) => string;\n encodeBytes: (bytes: number[], context?: EncodeContext | undefined) => string;\n fromByteString: (byteString: string) => number[];\n toByteString: (bytes: number[]) => string;\n}", "examples": [ { "language": "javascript", diff --git a/encoding/base64url.md b/encoding/base64url.md index 08026f4b..854c6677 100644 --- a/encoding/base64url.md +++ b/encoding/base64url.md @@ -7,42 +7,30 @@ Provides a way to encode strings and bytes from and into Base64URL. ```typescript { - decode: ( - text: string, - context?: { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array) => string; - }; - } - ) => string; + decode: (text: string, context?: DecodeContext | undefined) => string; decodeBytes: ( text: string, - context?: { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array) => string; - }; - } + context?: + | { + atob: (byteString: string) => string; + TextDecoder: new (encoding: string) => { + decode: (input?: Uint8Array | undefined) => string; + }; + } + | undefined ) => number[]; encode: ( text: string, - context?: { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string) => Uint8Array; - }; - } - ) => string; - encodeBytes: ( - bytes: number[], - context?: { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string) => Uint8Array; - }; - } + context?: + | { + btoa: (byteString: string) => string; + TextEncoder: new () => { + encode: (input?: string | undefined) => Uint8Array; + }; + } + | undefined ) => string; + encodeBytes: (bytes: number[], context?: EncodeContext | undefined) => string; fromByteString: (byteString: string) => number[]; toByteString: (bytes: number[]) => string; } diff --git a/is/README.md b/is/README.md index d0d174b9..82b7df8d 100644 --- a/is/README.md +++ b/is/README.md @@ -26,7 +26,7 @@ Checks if the given value is a byte. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean ``` @@ -90,7 +90,19 @@ Checks if given value is an integer. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean +``` + + +# nonNullable + +Checks and asserts the given value is not a null or undefined. + +## Type signature + + +```typescript +(val: T) => val is NonNullable ``` @@ -102,7 +114,7 @@ Checks if the given value is a number in a normal range [0, 1]. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean ``` diff --git a/is/byte.js b/is/byte.js index b25231df..2d422193 100644 --- a/is/byte.js +++ b/is/byte.js @@ -1,3 +1,4 @@ import integer from "./integer.js"; +import nonNullable from "./nonNullable.js"; -export default x => integer(x) && x >= 0 && x <= 255; +export default x => nonNullable(x) && integer(x) && x >= 0 && x <= 255; diff --git a/is/byte.json b/is/byte.json index 9bc1a4e3..bf1bd2bd 100644 --- a/is/byte.json +++ b/is/byte.json @@ -1,7 +1,7 @@ { "name": "byte", "description": "Checks if the given value is a byte.", - "signature": "(x?: number) => boolean", + "signature": "(x?: number | undefined) => boolean", "examples": [ { "language": "javascript", diff --git a/is/byte.md b/is/byte.md index 2237e937..ba16a89c 100644 --- a/is/byte.md +++ b/is/byte.md @@ -6,7 +6,7 @@ Checks if the given value is a byte. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean ``` diff --git a/is/index.js b/is/index.js index 2880557e..84d2ff61 100644 --- a/is/index.js +++ b/is/index.js @@ -4,6 +4,7 @@ import date from "./date.js"; import defined from "./defined.js"; import _function from "./function.js"; import integer from "./integer.js"; +import nonNullable from "./nonNullable.js"; import normal from "./normal.js"; import number from "./number.js"; import object from "./object.js"; @@ -16,6 +17,7 @@ export { defined, _function, integer, + nonNullable, normal, number, object, @@ -29,6 +31,7 @@ export default { defined, _function, integer, + nonNullable, normal, number, object, diff --git a/is/integer.js b/is/integer.js index b79db0fd..21e7e213 100644 --- a/is/integer.js +++ b/is/integer.js @@ -1,3 +1,4 @@ import number from "./number.js"; +import nonNullable from "./nonNullable.js"; -export default x => number(x) && Math.floor(x) === x; +export default x => nonNullable(x) && number(x) && Math.floor(x) === x; diff --git a/is/integer.json b/is/integer.json index 48670c9c..46c97e0e 100644 --- a/is/integer.json +++ b/is/integer.json @@ -1,7 +1,7 @@ { "name": "integer", "description": "Checks if given value is an integer.", - "signature": "(x?: number) => boolean", + "signature": "(x?: number | undefined) => boolean", "examples": [ { "language": "javascript", diff --git a/is/integer.md b/is/integer.md index b2226298..7330bddb 100644 --- a/is/integer.md +++ b/is/integer.md @@ -6,6 +6,6 @@ Checks if given value is an integer. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean ``` diff --git a/is/nonNullable.js b/is/nonNullable.js new file mode 100644 index 00000000..6de4af85 --- /dev/null +++ b/is/nonNullable.js @@ -0,0 +1 @@ +export default val => val !== undefined && val !== null; diff --git a/is/nonNullable.md b/is/nonNullable.md new file mode 100644 index 00000000..c45d8e8f --- /dev/null +++ b/is/nonNullable.md @@ -0,0 +1,11 @@ +# nonNullable + +Checks and asserts the given value is not a null or undefined. + +## Type signature + + +```typescript +(val: T) => val is NonNullable +``` + diff --git a/is/normal.js b/is/normal.js index 284b2b93..16332193 100644 --- a/is/normal.js +++ b/is/normal.js @@ -1,3 +1,4 @@ import number from "./number.js"; +import nonNullable from "./nonNullable.js"; -export default x => number(x) && x >= 0 && x <= 1; +export default x => nonNullable(x) && number(x) && x >= 0 && x <= 1; diff --git a/is/normal.json b/is/normal.json index ff1230a5..86395364 100644 --- a/is/normal.json +++ b/is/normal.json @@ -1,7 +1,7 @@ { "name": "normal", "description": "Checks if the given value is a number in a normal range [0, 1].", - "signature": "(x?: number) => boolean", + "signature": "(x?: number | undefined) => boolean", "examples": [ { "language": "javascript", diff --git a/is/normal.md b/is/normal.md index d460d7eb..3df4b167 100644 --- a/is/normal.md +++ b/is/normal.md @@ -6,6 +6,6 @@ Checks if the given value is a number in a normal range [0, 1]. ```typescript -(x?: number) => boolean +(x?: number | undefined) => boolean ``` diff --git a/is/number.js b/is/number.js index 819511f5..492cfe77 100644 --- a/is/number.js +++ b/is/number.js @@ -1,2 +1,7 @@ +import nonNullable from "./nonNullable.js"; + export default x => - typeof x === "number" && !Number.isNaN(x) && Number.isFinite(x); + nonNullable(x) && + typeof x === "number" && + !Number.isNaN(x) && + Number.isFinite(x); diff --git a/math/README.md b/math/README.md index f5d34067..d5257ff3 100644 --- a/math/README.md +++ b/math/README.md @@ -18,7 +18,7 @@ Calculates the average of given array of numbers. ```typescript -(xs?: number[]) => number +(xs?: number[] | undefined) => number ``` @@ -129,7 +129,7 @@ Calculates the median of the values. If there is an even number of items, the av ```typescript -(xs?: number[]) => number +(xs?: number[] | undefined) => number | undefined ``` diff --git a/math/average.json b/math/average.json index 9592d9ed..e51bdb49 100644 --- a/math/average.json +++ b/math/average.json @@ -1,7 +1,7 @@ { "name": "average", "description": "Calculates the average of given array of numbers.", - "signature": "(xs?: number[]) => number", + "signature": "(xs?: number[] | undefined) => number", "examples": [ { "language": "javascript", diff --git a/math/average.md b/math/average.md index 5af5847d..427b7b18 100644 --- a/math/average.md +++ b/math/average.md @@ -6,6 +6,6 @@ Calculates the average of given array of numbers. ```typescript -(xs?: number[]) => number +(xs?: number[] | undefined) => number ``` diff --git a/math/median.json b/math/median.json index 1f6743e9..5a1f07f6 100644 --- a/math/median.json +++ b/math/median.json @@ -1,7 +1,7 @@ { "name": "median", "description": "Calculates the median of the values. If there is an even number of items, the average of the middle ones is returned.", - "signature": "(xs?: number[]) => number", + "signature": "(xs?: number[] | undefined) => number | undefined", "examples": [ { "language": "javascript", diff --git a/math/median.md b/math/median.md index 29625828..e79892d8 100644 --- a/math/median.md +++ b/math/median.md @@ -6,6 +6,6 @@ Calculates the median of the values. If there is an even number of items, the av ```typescript -(xs?: number[]) => number +(xs?: number[] | undefined) => number | undefined ``` diff --git a/object/README.md b/object/README.md index e4f57227..66b99859 100644 --- a/object/README.md +++ b/object/README.md @@ -6,7 +6,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: object) => boolean +(xs?: object | undefined) => boolean ``` @@ -20,7 +20,12 @@ Applies the given parameters to the given dictionary of functions. ```typescript ( fs: ((...xs: any[]) => any)[] -) => (...xs: any[]) => object +) => ( + ...xs: any[] +) => { + [x: string]: any; + [x: number]: any; +} ``` @@ -195,7 +200,13 @@ Creates an object from array of key value pairs (entries). ```typescript -(keyValuePairs: [string, any][]) => object +{ + (entries: Iterable): { + [x: string]: T; + [x: number]: T; + }; + (entries: Iterable): any; +} ``` @@ -219,7 +230,7 @@ Checks if given key is present in the object. ```typescript -(key: string) => (xs?: any) => any +(key: string) => (xs?: any) => boolean ``` @@ -297,7 +308,12 @@ Merges two objects deeply. ```typescript -(a: object, b: object) => object +( + a: { + [index: string]: any; + }, + b: object +) => object ``` @@ -329,7 +345,7 @@ Checks if the given object is empty. ```typescript -(xs?: object) => boolean +(xs?: object | undefined) => boolean ``` @@ -341,6 +357,8 @@ Sorts the given object by a comparator. ```typescript -(f: any) => (xs: any) => object +( + f: (a: any, b: any) => number +) => (xs: object) => object ``` diff --git a/object/any.json b/object/any.json index 93088b21..f1f14f56 100644 --- a/object/any.json +++ b/object/any.json @@ -1,7 +1,7 @@ { "name": "any", "description": "Checks if the given array is present and it is not empty (contains at least one element).", - "signature": "(xs?: object) => boolean", + "signature": "(xs?: object | undefined) => boolean", "examples": [ { "language": "javascript", diff --git a/object/any.md b/object/any.md index 01b2942c..72b50f52 100644 --- a/object/any.md +++ b/object/any.md @@ -6,6 +6,6 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: object) => boolean +(xs?: object | undefined) => boolean ``` diff --git a/object/apply.json b/object/apply.json index 261f0593..0adf0f74 100644 --- a/object/apply.json +++ b/object/apply.json @@ -1,7 +1,7 @@ { "name": "apply", "description": "Applies the given parameters to the given dictionary of functions.", - "signature": "(\n fs: ((...xs: any[]) => any)[]\n) => (...xs: any[]) => object", + "signature": "(\n fs: ((...xs: any[]) => any)[]\n) => (\n ...xs: any[]\n) => {\n [x: string]: any;\n [x: number]: any;\n}", "examples": [ { "language": "javascript", diff --git a/object/apply.md b/object/apply.md index 9188d303..2317952b 100644 --- a/object/apply.md +++ b/object/apply.md @@ -8,6 +8,11 @@ Applies the given parameters to the given dictionary of functions. ```typescript ( fs: ((...xs: any[]) => any)[] -) => (...xs: any[]) => object +) => ( + ...xs: any[] +) => { + [x: string]: any; + [x: number]: any; +} ``` diff --git a/object/fromEntries.json b/object/fromEntries.json index 4c9e1192..97f3e160 100644 --- a/object/fromEntries.json +++ b/object/fromEntries.json @@ -1,7 +1,7 @@ { "name": "fromEntries", "description": "Creates an object from array of key value pairs (entries).", - "signature": "(keyValuePairs: [string, any][]) => object", + "signature": "{\n (entries: Iterable): {\n [x: string]: T;\n [x: number]: T;\n };\n (entries: Iterable): any;\n}", "examples": [ { "language": "javascript", diff --git a/object/fromEntries.md b/object/fromEntries.md index 6dd11534..f57d18a4 100644 --- a/object/fromEntries.md +++ b/object/fromEntries.md @@ -6,6 +6,12 @@ Creates an object from array of key value pairs (entries). ```typescript -(keyValuePairs: [string, any][]) => object +{ + (entries: Iterable): { + [x: string]: T; + [x: number]: T; + }; + (entries: Iterable): any; +} ``` diff --git a/object/hasKey.json b/object/hasKey.json index e0302ca0..e434e255 100644 --- a/object/hasKey.json +++ b/object/hasKey.json @@ -1,7 +1,7 @@ { "name": "hasKey", "description": "Checks if given key is present in the object.", - "signature": "(key: string) => (xs?: any) => any", + "signature": "(key: string) => (xs?: any) => boolean", "examples": [ { "language": "javascript", diff --git a/object/hasKey.md b/object/hasKey.md index fb89a043..91186ba7 100644 --- a/object/hasKey.md +++ b/object/hasKey.md @@ -6,6 +6,6 @@ Checks if given key is present in the object. ```typescript -(key: string) => (xs?: any) => any +(key: string) => (xs?: any) => boolean ``` diff --git a/object/merge.js b/object/merge.js index 24fc832b..3a428175 100644 --- a/object/merge.js +++ b/object/merge.js @@ -1,12 +1,13 @@ +import isNonNullable from "../is/nonNullable.js"; import isObject from "../is/object.js"; import map from "./map.js"; -const isNonNullishObject = x => x !== undefined && x !== null && isObject(x); +const isNonNullableObject = x => isNonNullable(x) && isObject(x); const merge = (a, b) => ({ ...a, ...map((value, key) => - isNonNullishObject(value) && isNonNullishObject(a[key]) + isNonNullableObject(value) && isNonNullableObject(a[key]) ? merge(a[key], value) : value )(b) diff --git a/object/merge.json b/object/merge.json index 8538d2ac..abd1806f 100644 --- a/object/merge.json +++ b/object/merge.json @@ -1,7 +1,7 @@ { "name": "merge", "description": "Merges two objects deeply.", - "signature": "(a: object, b: object) => object", + "signature": "(\n a: {\n [index: string]: any;\n },\n b: object\n) => object", "examples": [ { "language": "javascript", diff --git a/object/merge.md b/object/merge.md index d74ed2cd..6966e81a 100644 --- a/object/merge.md +++ b/object/merge.md @@ -6,7 +6,12 @@ Merges two objects deeply. ```typescript -(a: object, b: object) => object +( + a: { + [index: string]: any; + }, + b: object +) => object ``` diff --git a/object/none.json b/object/none.json index 88c0914f..1b583d27 100644 --- a/object/none.json +++ b/object/none.json @@ -1,7 +1,7 @@ { "name": "none", "description": "Checks if the given object is empty.", - "signature": "(xs?: object) => boolean", + "signature": "(xs?: object | undefined) => boolean", "examples": [ { "language": "javascript", diff --git a/object/none.md b/object/none.md index 45bc7b3f..0462eb2b 100644 --- a/object/none.md +++ b/object/none.md @@ -6,6 +6,6 @@ Checks if the given object is empty. ```typescript -(xs?: object) => boolean +(xs?: object | undefined) => boolean ``` diff --git a/object/sort.json b/object/sort.json index 423a3e4a..2f1bbb63 100644 --- a/object/sort.json +++ b/object/sort.json @@ -1,7 +1,7 @@ { "name": "sort", "description": "Sorts the given object by a comparator.", - "signature": "(f: any) => (xs: any) => object", + "signature": "(\n f: (a: any, b: any) => number\n) => (xs: object) => object", "examples": [ { "language": "javascript", diff --git a/object/sort.md b/object/sort.md index d6515960..0e678206 100644 --- a/object/sort.md +++ b/object/sort.md @@ -6,6 +6,8 @@ Sorts the given object by a comparator. ```typescript -(f: any) => (xs: any) => object +( + f: (a: any, b: any) => number +) => (xs: object) => object ``` diff --git a/query/README.md b/query/README.md index 5dbadca9..c3305c9b 100644 --- a/query/README.md +++ b/query/README.md @@ -6,7 +6,12 @@ Parses a query string into an object. ```typescript -(xs?: string) => object +( + xs?: string +) => { + [x: string]: string | boolean; + [x: number]: string | boolean; +} ``` @@ -30,6 +35,6 @@ Serializes the given object into a query string. ```typescript -(xs?: {}) => string +(xs?: { [index: string]: any }) => string ``` diff --git a/query/parse.json b/query/parse.json index 6463b774..60cb1720 100644 --- a/query/parse.json +++ b/query/parse.json @@ -1,7 +1,7 @@ { "name": "parse", "description": "Parses a query string into an object.", - "signature": "(xs?: string) => object", + "signature": "(\n xs?: string\n) => {\n [x: string]: string | boolean;\n [x: number]: string | boolean;\n}", "examples": [ { "language": "javascript", diff --git a/query/parse.md b/query/parse.md index c5c300f5..8e7b4cde 100644 --- a/query/parse.md +++ b/query/parse.md @@ -6,6 +6,11 @@ Parses a query string into an object. ```typescript -(xs?: string) => object +( + xs?: string +) => { + [x: string]: string | boolean; + [x: number]: string | boolean; +} ``` diff --git a/query/serialize.js b/query/serialize.js index 130a257e..681ea6b9 100644 --- a/query/serialize.js +++ b/query/serialize.js @@ -3,7 +3,7 @@ import entries from "../object/entries.js"; export default (xs = {}) => entries(xs) .filter(([, value]) => Boolean(value) || value === 0) - .map(pair => pair.map(encodeURIComponent)) + .map(pair => pair.map(value => encodeURIComponent(value))) .reduce( (acc, [key, value]) => [ ...acc, diff --git a/query/serialize.json b/query/serialize.json index 041609ef..3d7f3e50 100644 --- a/query/serialize.json +++ b/query/serialize.json @@ -1,7 +1,7 @@ { "name": "serialize", "description": "Serializes the given object into a query string.", - "signature": "(xs?: {}) => string", + "signature": "(xs?: { [index: string]: any }) => string", "examples": [ { "language": "javascript", diff --git a/query/serialize.md b/query/serialize.md index 489d0be2..64666971 100644 --- a/query/serialize.md +++ b/query/serialize.md @@ -6,6 +6,6 @@ Serializes the given object into a query string. ```typescript -(xs?: {}) => string +(xs?: { [index: string]: any }) => string ``` diff --git a/range/README.md b/range/README.md index 8f3eab5e..34683952 100644 --- a/range/README.md +++ b/range/README.md @@ -6,7 +6,7 @@ Checks if the given range is empty. ```typescript -([min, max]: [any, any]) => boolean +([min, max]: [number, number]) => boolean ``` @@ -27,7 +27,10 @@ Checks if the given ranges are equal. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => boolean +( + [a, b]: [number, number], + [c, d]: [number, number] +) => boolean ``` @@ -39,7 +42,7 @@ Computes the signed length of the given range. ```typescript -([min, max]: [any, any]) => number +([min, max]: [number, number]) => number ``` diff --git a/range/empty.json b/range/empty.json index 63c09b2a..b6a44e18 100644 --- a/range/empty.json +++ b/range/empty.json @@ -1,7 +1,7 @@ { "name": "empty", "description": "Checks if the given range is empty.", - "signature": "([min, max]: [any, any]) => boolean", + "signature": "([min, max]: [number, number]) => boolean", "examples": [ { "language": "javascript", diff --git a/range/empty.md b/range/empty.md index 16fda656..902a2436 100644 --- a/range/empty.md +++ b/range/empty.md @@ -6,7 +6,7 @@ Checks if the given range is empty. ```typescript -([min, max]: [any, any]) => boolean +([min, max]: [number, number]) => boolean ``` diff --git a/range/equals.json b/range/equals.json index 6e0992e8..c4023ff4 100644 --- a/range/equals.json +++ b/range/equals.json @@ -1,7 +1,7 @@ { "name": "equals", "description": "Checks if the given ranges are equal.", - "signature": "([a, b]: [any, any], [c, d]: [any, any]) => boolean", + "signature": "(\n [a, b]: [number, number],\n [c, d]: [number, number]\n) => boolean", "examples": [ { "language": "javascript", diff --git a/range/equals.md b/range/equals.md index 0210ff5a..2fd47b77 100644 --- a/range/equals.md +++ b/range/equals.md @@ -6,6 +6,9 @@ Checks if the given ranges are equal. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => boolean +( + [a, b]: [number, number], + [c, d]: [number, number] +) => boolean ``` diff --git a/range/length.json b/range/length.json index 5436cc92..af5a5465 100644 --- a/range/length.json +++ b/range/length.json @@ -1,7 +1,7 @@ { "name": "length", "description": "Computes the signed length of the given range.", - "signature": "([min, max]: [any, any]) => number", + "signature": "([min, max]: [number, number]) => number", "examples": [ { "language": "javascript", diff --git a/range/length.md b/range/length.md index dc0e39a3..a8b8dc28 100644 --- a/range/length.md +++ b/range/length.md @@ -6,6 +6,6 @@ Computes the signed length of the given range. ```typescript -([min, max]: [any, any]) => number +([min, max]: [number, number]) => number ``` diff --git a/string/README.md b/string/README.md index 95fdeffe..111881ef 100644 --- a/string/README.md +++ b/string/README.md @@ -86,7 +86,7 @@ Checks if the given string is present and is not empty or all whitespace. ```typescript -(x?: string) => boolean +(x?: string | undefined) => boolean ``` diff --git a/string/nonEmpty.json b/string/nonEmpty.json index 02c46172..690c9a45 100644 --- a/string/nonEmpty.json +++ b/string/nonEmpty.json @@ -1,7 +1,7 @@ { "name": "nonEmpty", "description": "Checks if the given string is present and is not empty or all whitespace.", - "signature": "(x?: string) => boolean", + "signature": "(x?: string | undefined) => boolean", "examples": [ { "language": "javascript", diff --git a/string/nonEmpty.md b/string/nonEmpty.md index 691c8291..c69b7d0c 100644 --- a/string/nonEmpty.md +++ b/string/nonEmpty.md @@ -6,6 +6,6 @@ Checks if the given string is present and is not empty or all whitespace. ```typescript -(x?: string) => boolean +(x?: string | undefined) => boolean ``` diff --git a/vector2/README.md b/vector2/README.md index 0f2cf614..7dc3a640 100644 --- a/vector2/README.md +++ b/vector2/README.md @@ -40,7 +40,10 @@ Calculates a cross product of the given vectors. Returns a scalar. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => number +( + [a, b]: [number, number], + [c, d]: [number, number] +) => number ``` @@ -52,7 +55,10 @@ Calculates a dot product of the given vectors. Returns a scalar. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => number +( + [a, b]: [number, number], + [c, d]: [number, number] +) => number ``` @@ -141,7 +147,7 @@ Normalizes the given vector. Returns [0, 0] vector for points. ```typescript -(vector: [number, number]) => number[] +(vector: [number, number]) => [number, number] ``` diff --git a/vector2/cross.json b/vector2/cross.json index ce55aa65..9214f26a 100644 --- a/vector2/cross.json +++ b/vector2/cross.json @@ -1,7 +1,7 @@ { "name": "cross", "description": "Calculates a cross product of the given vectors. Returns a scalar.", - "signature": "([a, b]: [any, any], [c, d]: [any, any]) => number", + "signature": "(\n [a, b]: [number, number],\n [c, d]: [number, number]\n) => number", "examples": [ { "language": "javascript", diff --git a/vector2/cross.md b/vector2/cross.md index ee43d9e1..72f7b55b 100644 --- a/vector2/cross.md +++ b/vector2/cross.md @@ -6,6 +6,9 @@ Calculates a cross product of the given vectors. Returns a scalar. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => number +( + [a, b]: [number, number], + [c, d]: [number, number] +) => number ``` diff --git a/vector2/dot.json b/vector2/dot.json index a61d5e30..1052dc37 100644 --- a/vector2/dot.json +++ b/vector2/dot.json @@ -1,7 +1,7 @@ { "name": "dot", "description": "Calculates a dot product of the given vectors. Returns a scalar.", - "signature": "([a, b]: [any, any], [c, d]: [any, any]) => number", + "signature": "(\n [a, b]: [number, number],\n [c, d]: [number, number]\n) => number", "examples": [ { "language": "javascript", diff --git a/vector2/dot.md b/vector2/dot.md index f307618b..bee5beb8 100644 --- a/vector2/dot.md +++ b/vector2/dot.md @@ -6,6 +6,9 @@ Calculates a dot product of the given vectors. Returns a scalar. ```typescript -([a, b]: [any, any], [c, d]: [any, any]) => number +( + [a, b]: [number, number], + [c, d]: [number, number] +) => number ``` diff --git a/vector2/normalize.js b/vector2/normalize.js index 49c0c810..c843a3d6 100644 --- a/vector2/normalize.js +++ b/vector2/normalize.js @@ -2,6 +2,7 @@ import length from "./length.js"; export default vector => { const magnitude = length(vector); + const [x, y] = vector; - return magnitude !== 0 ? vector.map(_ => _ / magnitude) : vector; + return magnitude !== 0 ? [x / magnitude, y / magnitude] : vector; }; diff --git a/vector2/normalize.json b/vector2/normalize.json index a81ef5de..026e6a0e 100644 --- a/vector2/normalize.json +++ b/vector2/normalize.json @@ -1,7 +1,7 @@ { "name": "normalize", "description": "Normalizes the given vector. Returns [0, 0] vector for points.", - "signature": "(vector: [number, number]) => number[]", + "signature": "(vector: [number, number]) => [number, number]", "examples": [ { "language": "javascript", diff --git a/vector2/normalize.md b/vector2/normalize.md index 17717177..04849d18 100644 --- a/vector2/normalize.md +++ b/vector2/normalize.md @@ -6,6 +6,6 @@ Normalizes the given vector. Returns [0, 0] vector for points. ```typescript -(vector: [number, number]) => number[] +(vector: [number, number]) => [number, number] ``` diff --git a/web/README.md b/web/README.md index a8c5128e..33d6bba3 100644 --- a/web/README.md +++ b/web/README.md @@ -41,10 +41,10 @@ Tests if the current event seems like an intent to open a new tab. Useful for cl metaKey, shiftKey }: { - button: any; - ctrlKey: any; - metaKey: any; - shiftKey: any; + button?: number | undefined; + ctrlKey?: boolean | undefined; + metaKey?: boolean | undefined; + shiftKey?: boolean | undefined; }) => boolean ``` diff --git a/web/events/README.md b/web/events/README.md index cc6dbfb7..3a8dfd6c 100644 --- a/web/events/README.md +++ b/web/events/README.md @@ -27,10 +27,10 @@ Tests if the current event seems like an intent to open a new tab. Useful for cl metaKey, shiftKey }: { - button: any; - ctrlKey: any; - metaKey: any; - shiftKey: any; + button?: number | undefined; + ctrlKey?: boolean | undefined; + metaKey?: boolean | undefined; + shiftKey?: boolean | undefined; }) => boolean ``` diff --git a/web/events/openInNewTabIntent.json b/web/events/openInNewTabIntent.json index aef9d1bb..735497e4 100644 --- a/web/events/openInNewTabIntent.json +++ b/web/events/openInNewTabIntent.json @@ -1,7 +1,7 @@ { "name": "openInNewTabIntent", "description": "Tests if the current event seems like an intent to open a new tab. Useful for client-side navigation handling.", - "signature": "({\n button,\n ctrlKey,\n metaKey,\n shiftKey\n}: {\n button: any;\n ctrlKey: any;\n metaKey: any;\n shiftKey: any;\n}) => boolean", + "signature": "({\n button,\n ctrlKey,\n metaKey,\n shiftKey\n}: {\n button?: number | undefined;\n ctrlKey?: boolean | undefined;\n metaKey?: boolean | undefined;\n shiftKey?: boolean | undefined;\n}) => boolean", "examples": [ { "language": "javascript", diff --git a/web/events/openInNewTabIntent.md b/web/events/openInNewTabIntent.md index 93b3f02a..48076f53 100644 --- a/web/events/openInNewTabIntent.md +++ b/web/events/openInNewTabIntent.md @@ -12,10 +12,10 @@ Tests if the current event seems like an intent to open a new tab. Useful for cl metaKey, shiftKey }: { - button: any; - ctrlKey: any; - metaKey: any; - shiftKey: any; + button?: number | undefined; + ctrlKey?: boolean | undefined; + metaKey?: boolean | undefined; + shiftKey?: boolean | undefined; }) => boolean ``` From f874d5eedff0441a49528b219a82f2748591a2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Zalewski?= Date: Fri, 3 Jan 2020 15:37:34 +0100 Subject: [PATCH 6/7] Compile twice to generate simpler type definition files --- compile.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/compile.js b/compile.js index 2fb6fe2f..88cb1f3f 100644 --- a/compile.js +++ b/compile.js @@ -76,21 +76,43 @@ const main = async cwd => { const command = [executable, ...args].join(" "); - console.time(command); - const windows = process.platform === "win32"; - const { stdout, stderr } = await execAsync(command, { + const execOptions = { windowsVerbatimArguments: windows - }); + }; + + console.time(command); + + const { stdout, stderr } = await execAsync(command, execOptions); console.timeEnd(command); - console.log(`Compiled ${relativeFilePath}`); + console.log(`Compiled with strict mode ${relativeFilePath}`); if (stdout || stderr) { console.log({ stdout, stderr }); } + + const nonStrictCommand = [ + executable, + ...args.filter(x => x !== "--strict") + ].join(" "); + + console.time(nonStrictCommand); + + const { stdout: secondStdout, stderr: secondStderr } = await execAsync( + nonStrictCommand, + execOptions + ); + + console.timeEnd(nonStrictCommand); + + console.log(`Compiled without strict mode ${relativeFilePath}`); + + if (secondStdout || secondStderr) { + console.log({ secondStdout, secondStderr }); + } } catch (error) { console.error(error); From 59f5bce78c6fe44f07a26000cc62d447d6c40fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Zalewski?= Date: Fri, 3 Jan 2020 15:37:52 +0100 Subject: [PATCH 7/7] Regenerate code and docs --- README.md | 123 +++++++++++------------------ array/README.md | 15 ++-- array/any.json | 2 +- array/any.md | 2 +- array/differs.json | 2 +- array/differs.md | 5 +- array/empty.json | 2 +- array/empty.md | 2 +- array/flatten.json | 2 +- array/flatten.md | 2 +- array/shuffle.json | 2 +- array/shuffle.md | 2 +- array/sort.json | 2 +- array/sort.md | 2 +- async/README.md | 2 +- async/sequence.json | 2 +- async/sequence.md | 2 +- date/README.md | 10 +-- date/dayRange.json | 2 +- date/dayRange.md | 10 +-- debug/README.md | 16 ++-- debug/diff.json | 2 +- debug/diff.md | 16 ++-- encoding/README.md | 32 ++++---- encoding/base64url.json | 2 +- encoding/base64url.md | 32 ++++---- is/README.md | 6 +- is/byte.json | 2 +- is/byte.md | 2 +- is/integer.json | 2 +- is/integer.md | 2 +- is/normal.json | 2 +- is/normal.md | 2 +- math/README.md | 4 +- math/average.json | 2 +- math/average.md | 2 +- math/median.json | 2 +- math/median.md | 2 +- object/README.md | 21 ++--- object/any.json | 2 +- object/any.md | 2 +- object/apply.json | 2 +- object/apply.md | 7 +- object/fromEntries.json | 2 +- object/fromEntries.md | 8 +- object/hasKey.json | 2 +- object/hasKey.md | 2 +- object/none.json | 2 +- object/none.md | 2 +- query/README.md | 7 +- query/parse.json | 2 +- query/parse.md | 7 +- string/README.md | 2 +- string/nonEmpty.json | 2 +- string/nonEmpty.md | 2 +- web/README.md | 8 +- web/events/README.md | 8 +- web/events/openInNewTabIntent.json | 2 +- web/events/openInNewTabIntent.md | 8 +- 59 files changed, 171 insertions(+), 252 deletions(-) diff --git a/README.md b/README.md index 9c1b319a..bc92ad7f 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: any[] | undefined) => boolean +(xs?: any[]) => boolean ``` @@ -70,10 +70,7 @@ Checks if two arrays are not equal. ```typescript -( - xs?: any[] | undefined, - ys?: any[] | undefined -) => boolean +(xs?: any[], ys?: any[]) => boolean ``` @@ -97,7 +94,7 @@ Empty array. ```typescript -never[] +any[] ``` @@ -196,7 +193,7 @@ Flattens the nested arrays by a single level. ```typescript -(xs: any) => never[] +(xs: any) => any[] ``` @@ -410,7 +407,7 @@ Shuffles the given array in random order with Math.random as the default. ```typescript -(xs: any, random?: (() => number) | undefined) => any[] +(xs: any, random?: () => number) => any[] ``` @@ -459,7 +456,7 @@ Sorts the given array without mutating it. ```typescript ( - f?: ((a: any, b: any) => number) | undefined + f?: (a: any, b: any) => number ) => (xs: any[]) => any[] ``` @@ -563,7 +560,7 @@ Runs the given tasks in a sequence. ```typescript -(tasks: (() => Promise)[]) => Promise +(tasks: (() => Promise)[]) => Promise ``` @@ -647,11 +644,11 @@ Runs the given tasks in a sequence. now, timezoneOffset }: { - iso?: boolean | undefined; - local?: boolean | undefined; - now?: Date | undefined; - timezoneOffset?: number | undefined; -}) => (date?: string | number | Date | undefined) => string[] + iso?: boolean; + local?: boolean; + now?: Date; + timezoneOffset?: number; +}) => (date?: string | number | Date) => string[] ``` @@ -1042,16 +1039,12 @@ Computes a difference between two objects. ```typescript ( - obj1?: - | { - [index: string]: any; - } - | undefined, - obj2?: - | { - [index: string]: any; - } - | undefined + obj1?: { + [index: string]: any; + }, + obj2?: { + [index: string]: any; + } ) => object ``` @@ -1067,30 +1060,26 @@ Provides a way to encode strings and bytes from and into Base64URL. ```typescript { - decode: (text: string, context?: DecodeContext | undefined) => string; + decode: (text: string, context?: DecodeContext) => string; decodeBytes: ( text: string, - context?: - | { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array | undefined) => string; - }; - } - | undefined + context?: { + atob: (byteString: string) => string; + TextDecoder: new (encoding: string) => { + decode: (input?: Uint8Array) => string; + }; + } ) => number[]; encode: ( text: string, - context?: - | { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string | undefined) => Uint8Array; - }; - } - | undefined + context?: { + btoa: (byteString: string) => string; + TextEncoder: new () => { + encode: (input?: string) => Uint8Array; + }; + } ) => string; - encodeBytes: (bytes: number[], context?: EncodeContext | undefined) => string; + encodeBytes: (bytes: number[], context?: EncodeContext) => string; fromByteString: (byteString: string) => number[]; toByteString: (bytes: number[]) => string; } @@ -1283,7 +1272,7 @@ Checks if the given value is a byte. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` @@ -1347,7 +1336,7 @@ Checks if given value is an integer. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` @@ -1371,7 +1360,7 @@ Checks if the given value is a number in a normal range [0, 1]. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` @@ -1433,7 +1422,7 @@ Calculates the average of given array of numbers. ```typescript -(xs?: number[] | undefined) => number +(xs?: number[]) => number ``` @@ -1544,7 +1533,7 @@ Calculates the median of the values. If there is an even number of items, the av ```typescript -(xs?: number[] | undefined) => number | undefined +(xs?: number[]) => number ``` @@ -1618,7 +1607,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: object | undefined) => boolean +(xs?: object) => boolean ``` @@ -1632,12 +1621,7 @@ Applies the given parameters to the given dictionary of functions. ```typescript ( fs: ((...xs: any[]) => any)[] -) => ( - ...xs: any[] -) => { - [x: string]: any; - [x: number]: any; -} +) => (...xs: any[]) => object ``` @@ -1812,13 +1796,7 @@ Creates an object from array of key value pairs (entries). ```typescript -{ - (entries: Iterable): { - [x: string]: T; - [x: number]: T; - }; - (entries: Iterable): any; -} +(keyValuePairs: [string, any][]) => object ``` @@ -1842,7 +1820,7 @@ Checks if given key is present in the object. ```typescript -(key: string) => (xs?: any) => boolean +(key: string) => (xs?: any) => any ``` @@ -1957,7 +1935,7 @@ Checks if the given object is empty. ```typescript -(xs?: object | undefined) => boolean +(xs?: object) => boolean ``` @@ -1985,12 +1963,7 @@ Parses a query string into an object. ```typescript -( - xs?: string -) => { - [x: string]: string | boolean; - [x: number]: string | boolean; -} +(xs?: string) => object ``` @@ -2187,7 +2160,7 @@ Checks if the given string is present and is not empty or all whitespace. ```typescript -(x?: string | undefined) => boolean +(x?: string) => boolean ``` @@ -2528,10 +2501,10 @@ Tests if the current event seems like an intent to open a new tab. Useful for cl metaKey, shiftKey }: { - button?: number | undefined; - ctrlKey?: boolean | undefined; - metaKey?: boolean | undefined; - shiftKey?: boolean | undefined; + button?: number; + ctrlKey?: boolean; + metaKey?: boolean; + shiftKey?: boolean; }) => boolean ``` diff --git a/array/README.md b/array/README.md index 2c9b0226..28e53f64 100644 --- a/array/README.md +++ b/array/README.md @@ -6,7 +6,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: any[] | undefined) => boolean +(xs?: any[]) => boolean ``` @@ -59,10 +59,7 @@ Checks if two arrays are not equal. ```typescript -( - xs?: any[] | undefined, - ys?: any[] | undefined -) => boolean +(xs?: any[], ys?: any[]) => boolean ``` @@ -86,7 +83,7 @@ Empty array. ```typescript -never[] +any[] ``` @@ -185,7 +182,7 @@ Flattens the nested arrays by a single level. ```typescript -(xs: any) => never[] +(xs: any) => any[] ``` @@ -399,7 +396,7 @@ Shuffles the given array in random order with Math.random as the default. ```typescript -(xs: any, random?: (() => number) | undefined) => any[] +(xs: any, random?: () => number) => any[] ``` @@ -448,7 +445,7 @@ Sorts the given array without mutating it. ```typescript ( - f?: ((a: any, b: any) => number) | undefined + f?: (a: any, b: any) => number ) => (xs: any[]) => any[] ``` diff --git a/array/any.json b/array/any.json index 04a32fcb..df37c1f6 100644 --- a/array/any.json +++ b/array/any.json @@ -1,7 +1,7 @@ { "name": "any", "description": "Checks if the given array is present and it is not empty (contains at least one element).", - "signature": "(xs?: any[] | undefined) => boolean", + "signature": "(xs?: any[]) => boolean", "examples": [ { "language": "javascript", diff --git a/array/any.md b/array/any.md index 9544ee19..097cfbe6 100644 --- a/array/any.md +++ b/array/any.md @@ -6,7 +6,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: any[] | undefined) => boolean +(xs?: any[]) => boolean ``` diff --git a/array/differs.json b/array/differs.json index 4cf75396..e97011db 100644 --- a/array/differs.json +++ b/array/differs.json @@ -1,7 +1,7 @@ { "name": "differs", "description": "Checks if two arrays are not equal.", - "signature": "(\n xs?: any[] | undefined,\n ys?: any[] | undefined\n) => boolean", + "signature": "(xs?: any[], ys?: any[]) => boolean", "examples": [ { "language": "javascript", diff --git a/array/differs.md b/array/differs.md index 6d81b32f..c41ba69d 100644 --- a/array/differs.md +++ b/array/differs.md @@ -6,9 +6,6 @@ Checks if two arrays are not equal. ```typescript -( - xs?: any[] | undefined, - ys?: any[] | undefined -) => boolean +(xs?: any[], ys?: any[]) => boolean ``` diff --git a/array/empty.json b/array/empty.json index 588272b3..8516b4bc 100644 --- a/array/empty.json +++ b/array/empty.json @@ -1,7 +1,7 @@ { "name": "empty", "description": "Empty array.", - "signature": "never[]", + "signature": "any[]", "examples": [ { "language": "javascript", diff --git a/array/empty.md b/array/empty.md index 7a166c53..8348b892 100644 --- a/array/empty.md +++ b/array/empty.md @@ -6,7 +6,7 @@ Empty array. ```typescript -never[] +any[] ``` diff --git a/array/flatten.json b/array/flatten.json index 31bf7f39..bd8a2eb0 100644 --- a/array/flatten.json +++ b/array/flatten.json @@ -1,7 +1,7 @@ { "name": "flatten", "description": "Flattens the nested arrays by a single level.", - "signature": "(xs: any) => never[]", + "signature": "(xs: any) => any[]", "examples": [ { "language": "javascript", diff --git a/array/flatten.md b/array/flatten.md index a95dceb6..42c98153 100644 --- a/array/flatten.md +++ b/array/flatten.md @@ -6,6 +6,6 @@ Flattens the nested arrays by a single level. ```typescript -(xs: any) => never[] +(xs: any) => any[] ``` diff --git a/array/shuffle.json b/array/shuffle.json index 1d31c0e2..25c3db87 100644 --- a/array/shuffle.json +++ b/array/shuffle.json @@ -1,7 +1,7 @@ { "name": "shuffle", "description": "Shuffles the given array in random order with Math.random as the default.", - "signature": "(xs: any, random?: (() => number) | undefined) => any[]", + "signature": "(xs: any, random?: () => number) => any[]", "examples": [ { "language": "javascript", diff --git a/array/shuffle.md b/array/shuffle.md index 937edefb..8bc533c5 100644 --- a/array/shuffle.md +++ b/array/shuffle.md @@ -6,6 +6,6 @@ Shuffles the given array in random order with Math.random as the default. ```typescript -(xs: any, random?: (() => number) | undefined) => any[] +(xs: any, random?: () => number) => any[] ``` diff --git a/array/sort.json b/array/sort.json index a3fff1cc..fdd25ab7 100644 --- a/array/sort.json +++ b/array/sort.json @@ -1,7 +1,7 @@ { "name": "sort", "description": "Sorts the given array without mutating it.", - "signature": "(\n f?: ((a: any, b: any) => number) | undefined\n) => (xs: any[]) => any[]", + "signature": "(\n f?: (a: any, b: any) => number\n) => (xs: any[]) => any[]", "examples": [ { "language": "javascript", diff --git a/array/sort.md b/array/sort.md index 1e225139..f4d21c6a 100644 --- a/array/sort.md +++ b/array/sort.md @@ -7,7 +7,7 @@ Sorts the given array without mutating it. ```typescript ( - f?: ((a: any, b: any) => number) | undefined + f?: (a: any, b: any) => number ) => (xs: any[]) => any[] ``` diff --git a/async/README.md b/async/README.md index 0bd12192..e8a1ba64 100644 --- a/async/README.md +++ b/async/README.md @@ -33,6 +33,6 @@ Runs the given tasks in a sequence. ```typescript -(tasks: (() => Promise)[]) => Promise +(tasks: (() => Promise)[]) => Promise ``` diff --git a/async/sequence.json b/async/sequence.json index a278c3f1..77f0ed52 100644 --- a/async/sequence.json +++ b/async/sequence.json @@ -1,7 +1,7 @@ { "name": "sequence", "description": "Runs the given tasks in a sequence.", - "signature": "(tasks: (() => Promise)[]) => Promise", + "signature": "(tasks: (() => Promise)[]) => Promise", "examples": [ { "language": "javascript", diff --git a/async/sequence.md b/async/sequence.md index 495eb7af..75661873 100644 --- a/async/sequence.md +++ b/async/sequence.md @@ -6,6 +6,6 @@ Runs the given tasks in a sequence. ```typescript -(tasks: (() => Promise)[]) => Promise +(tasks: (() => Promise)[]) => Promise ``` diff --git a/date/README.md b/date/README.md index 23bdb7f9..46c3f123 100644 --- a/date/README.md +++ b/date/README.md @@ -76,11 +76,11 @@ now, timezoneOffset }: { - iso?: boolean | undefined; - local?: boolean | undefined; - now?: Date | undefined; - timezoneOffset?: number | undefined; -}) => (date?: string | number | Date | undefined) => string[] + iso?: boolean; + local?: boolean; + now?: Date; + timezoneOffset?: number; +}) => (date?: string | number | Date) => string[] ``` diff --git a/date/dayRange.json b/date/dayRange.json index 32ab999e..76b43def 100644 --- a/date/dayRange.json +++ b/date/dayRange.json @@ -1,7 +1,7 @@ { "name": "dayRange", "description": "TODO: Fill short description here.", - "signature": "({\n iso,\n local,\n now,\n timezoneOffset\n}: {\n iso?: boolean | undefined;\n local?: boolean | undefined;\n now?: Date | undefined;\n timezoneOffset?: number | undefined;\n}) => (date?: string | number | Date | undefined) => string[]", + "signature": "({\n iso,\n local,\n now,\n timezoneOffset\n}: {\n iso?: boolean;\n local?: boolean;\n now?: Date;\n timezoneOffset?: number;\n}) => (date?: string | number | Date) => string[]", "examples": [ { "language": "javascript", diff --git a/date/dayRange.md b/date/dayRange.md index ac3c7732..a0aa3418 100644 --- a/date/dayRange.md +++ b/date/dayRange.md @@ -10,10 +10,10 @@ now, timezoneOffset }: { - iso?: boolean | undefined; - local?: boolean | undefined; - now?: Date | undefined; - timezoneOffset?: number | undefined; -}) => (date?: string | number | Date | undefined) => string[] + iso?: boolean; + local?: boolean; + now?: Date; + timezoneOffset?: number; +}) => (date?: string | number | Date) => string[] ``` diff --git a/debug/README.md b/debug/README.md index 95ac43a7..70607335 100644 --- a/debug/README.md +++ b/debug/README.md @@ -22,16 +22,12 @@ Computes a difference between two objects. ```typescript ( - obj1?: - | { - [index: string]: any; - } - | undefined, - obj2?: - | { - [index: string]: any; - } - | undefined + obj1?: { + [index: string]: any; + }, + obj2?: { + [index: string]: any; + } ) => object ``` diff --git a/debug/diff.json b/debug/diff.json index 7be669fa..3047f61b 100644 --- a/debug/diff.json +++ b/debug/diff.json @@ -1,7 +1,7 @@ { "name": "diff", "description": "Computes a difference between two objects.", - "signature": "(\n obj1?:\n | {\n [index: string]: any;\n }\n | undefined,\n obj2?:\n | {\n [index: string]: any;\n }\n | undefined\n) => object", + "signature": "(\n obj1?: {\n [index: string]: any;\n },\n obj2?: {\n [index: string]: any;\n }\n) => object", "examples": [ { "language": "javascript", diff --git a/debug/diff.md b/debug/diff.md index e07498b6..a0d09d5f 100644 --- a/debug/diff.md +++ b/debug/diff.md @@ -7,16 +7,12 @@ Computes a difference between two objects. ```typescript ( - obj1?: - | { - [index: string]: any; - } - | undefined, - obj2?: - | { - [index: string]: any; - } - | undefined + obj1?: { + [index: string]: any; + }, + obj2?: { + [index: string]: any; + } ) => object ``` diff --git a/encoding/README.md b/encoding/README.md index 854c6677..78bb2f76 100644 --- a/encoding/README.md +++ b/encoding/README.md @@ -7,30 +7,26 @@ Provides a way to encode strings and bytes from and into Base64URL. ```typescript { - decode: (text: string, context?: DecodeContext | undefined) => string; + decode: (text: string, context?: DecodeContext) => string; decodeBytes: ( text: string, - context?: - | { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array | undefined) => string; - }; - } - | undefined + context?: { + atob: (byteString: string) => string; + TextDecoder: new (encoding: string) => { + decode: (input?: Uint8Array) => string; + }; + } ) => number[]; encode: ( text: string, - context?: - | { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string | undefined) => Uint8Array; - }; - } - | undefined + context?: { + btoa: (byteString: string) => string; + TextEncoder: new () => { + encode: (input?: string) => Uint8Array; + }; + } ) => string; - encodeBytes: (bytes: number[], context?: EncodeContext | undefined) => string; + encodeBytes: (bytes: number[], context?: EncodeContext) => string; fromByteString: (byteString: string) => number[]; toByteString: (bytes: number[]) => string; } diff --git a/encoding/base64url.json b/encoding/base64url.json index d692d5f9..34c52133 100644 --- a/encoding/base64url.json +++ b/encoding/base64url.json @@ -1,7 +1,7 @@ { "name": "base64url", "description": "Provides a way to encode strings and bytes from and into Base64URL.", - "signature": "{\n decode: (text: string, context?: DecodeContext | undefined) => string;\n decodeBytes: (\n text: string,\n context?:\n | {\n atob: (byteString: string) => string;\n TextDecoder: new (encoding: string) => {\n decode: (input?: Uint8Array | undefined) => string;\n };\n }\n | undefined\n ) => number[];\n encode: (\n text: string,\n context?:\n | {\n btoa: (byteString: string) => string;\n TextEncoder: new () => {\n encode: (input?: string | undefined) => Uint8Array;\n };\n }\n | undefined\n ) => string;\n encodeBytes: (bytes: number[], context?: EncodeContext | undefined) => string;\n fromByteString: (byteString: string) => number[];\n toByteString: (bytes: number[]) => string;\n}", + "signature": "{\n decode: (text: string, context?: DecodeContext) => string;\n decodeBytes: (\n text: string,\n context?: {\n atob: (byteString: string) => string;\n TextDecoder: new (encoding: string) => {\n decode: (input?: Uint8Array) => string;\n };\n }\n ) => number[];\n encode: (\n text: string,\n context?: {\n btoa: (byteString: string) => string;\n TextEncoder: new () => {\n encode: (input?: string) => Uint8Array;\n };\n }\n ) => string;\n encodeBytes: (bytes: number[], context?: EncodeContext) => string;\n fromByteString: (byteString: string) => number[];\n toByteString: (bytes: number[]) => string;\n}", "examples": [ { "language": "javascript", diff --git a/encoding/base64url.md b/encoding/base64url.md index 854c6677..78bb2f76 100644 --- a/encoding/base64url.md +++ b/encoding/base64url.md @@ -7,30 +7,26 @@ Provides a way to encode strings and bytes from and into Base64URL. ```typescript { - decode: (text: string, context?: DecodeContext | undefined) => string; + decode: (text: string, context?: DecodeContext) => string; decodeBytes: ( text: string, - context?: - | { - atob: (byteString: string) => string; - TextDecoder: new (encoding: string) => { - decode: (input?: Uint8Array | undefined) => string; - }; - } - | undefined + context?: { + atob: (byteString: string) => string; + TextDecoder: new (encoding: string) => { + decode: (input?: Uint8Array) => string; + }; + } ) => number[]; encode: ( text: string, - context?: - | { - btoa: (byteString: string) => string; - TextEncoder: new () => { - encode: (input?: string | undefined) => Uint8Array; - }; - } - | undefined + context?: { + btoa: (byteString: string) => string; + TextEncoder: new () => { + encode: (input?: string) => Uint8Array; + }; + } ) => string; - encodeBytes: (bytes: number[], context?: EncodeContext | undefined) => string; + encodeBytes: (bytes: number[], context?: EncodeContext) => string; fromByteString: (byteString: string) => number[]; toByteString: (bytes: number[]) => string; } diff --git a/is/README.md b/is/README.md index 82b7df8d..7b2cf479 100644 --- a/is/README.md +++ b/is/README.md @@ -26,7 +26,7 @@ Checks if the given value is a byte. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` @@ -90,7 +90,7 @@ Checks if given value is an integer. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` @@ -114,7 +114,7 @@ Checks if the given value is a number in a normal range [0, 1]. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` diff --git a/is/byte.json b/is/byte.json index bf1bd2bd..9bc1a4e3 100644 --- a/is/byte.json +++ b/is/byte.json @@ -1,7 +1,7 @@ { "name": "byte", "description": "Checks if the given value is a byte.", - "signature": "(x?: number | undefined) => boolean", + "signature": "(x?: number) => boolean", "examples": [ { "language": "javascript", diff --git a/is/byte.md b/is/byte.md index ba16a89c..2237e937 100644 --- a/is/byte.md +++ b/is/byte.md @@ -6,7 +6,7 @@ Checks if the given value is a byte. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` diff --git a/is/integer.json b/is/integer.json index 46c97e0e..48670c9c 100644 --- a/is/integer.json +++ b/is/integer.json @@ -1,7 +1,7 @@ { "name": "integer", "description": "Checks if given value is an integer.", - "signature": "(x?: number | undefined) => boolean", + "signature": "(x?: number) => boolean", "examples": [ { "language": "javascript", diff --git a/is/integer.md b/is/integer.md index 7330bddb..b2226298 100644 --- a/is/integer.md +++ b/is/integer.md @@ -6,6 +6,6 @@ Checks if given value is an integer. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` diff --git a/is/normal.json b/is/normal.json index 86395364..ff1230a5 100644 --- a/is/normal.json +++ b/is/normal.json @@ -1,7 +1,7 @@ { "name": "normal", "description": "Checks if the given value is a number in a normal range [0, 1].", - "signature": "(x?: number | undefined) => boolean", + "signature": "(x?: number) => boolean", "examples": [ { "language": "javascript", diff --git a/is/normal.md b/is/normal.md index 3df4b167..d460d7eb 100644 --- a/is/normal.md +++ b/is/normal.md @@ -6,6 +6,6 @@ Checks if the given value is a number in a normal range [0, 1]. ```typescript -(x?: number | undefined) => boolean +(x?: number) => boolean ``` diff --git a/math/README.md b/math/README.md index d5257ff3..f5d34067 100644 --- a/math/README.md +++ b/math/README.md @@ -18,7 +18,7 @@ Calculates the average of given array of numbers. ```typescript -(xs?: number[] | undefined) => number +(xs?: number[]) => number ``` @@ -129,7 +129,7 @@ Calculates the median of the values. If there is an even number of items, the av ```typescript -(xs?: number[] | undefined) => number | undefined +(xs?: number[]) => number ``` diff --git a/math/average.json b/math/average.json index e51bdb49..9592d9ed 100644 --- a/math/average.json +++ b/math/average.json @@ -1,7 +1,7 @@ { "name": "average", "description": "Calculates the average of given array of numbers.", - "signature": "(xs?: number[] | undefined) => number", + "signature": "(xs?: number[]) => number", "examples": [ { "language": "javascript", diff --git a/math/average.md b/math/average.md index 427b7b18..5af5847d 100644 --- a/math/average.md +++ b/math/average.md @@ -6,6 +6,6 @@ Calculates the average of given array of numbers. ```typescript -(xs?: number[] | undefined) => number +(xs?: number[]) => number ``` diff --git a/math/median.json b/math/median.json index 5a1f07f6..1f6743e9 100644 --- a/math/median.json +++ b/math/median.json @@ -1,7 +1,7 @@ { "name": "median", "description": "Calculates the median of the values. If there is an even number of items, the average of the middle ones is returned.", - "signature": "(xs?: number[] | undefined) => number | undefined", + "signature": "(xs?: number[]) => number", "examples": [ { "language": "javascript", diff --git a/math/median.md b/math/median.md index e79892d8..29625828 100644 --- a/math/median.md +++ b/math/median.md @@ -6,6 +6,6 @@ Calculates the median of the values. If there is an even number of items, the av ```typescript -(xs?: number[] | undefined) => number | undefined +(xs?: number[]) => number ``` diff --git a/object/README.md b/object/README.md index 66b99859..3a155675 100644 --- a/object/README.md +++ b/object/README.md @@ -6,7 +6,7 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: object | undefined) => boolean +(xs?: object) => boolean ``` @@ -20,12 +20,7 @@ Applies the given parameters to the given dictionary of functions. ```typescript ( fs: ((...xs: any[]) => any)[] -) => ( - ...xs: any[] -) => { - [x: string]: any; - [x: number]: any; -} +) => (...xs: any[]) => object ``` @@ -200,13 +195,7 @@ Creates an object from array of key value pairs (entries). ```typescript -{ - (entries: Iterable): { - [x: string]: T; - [x: number]: T; - }; - (entries: Iterable): any; -} +(keyValuePairs: [string, any][]) => object ``` @@ -230,7 +219,7 @@ Checks if given key is present in the object. ```typescript -(key: string) => (xs?: any) => boolean +(key: string) => (xs?: any) => any ``` @@ -345,7 +334,7 @@ Checks if the given object is empty. ```typescript -(xs?: object | undefined) => boolean +(xs?: object) => boolean ``` diff --git a/object/any.json b/object/any.json index f1f14f56..93088b21 100644 --- a/object/any.json +++ b/object/any.json @@ -1,7 +1,7 @@ { "name": "any", "description": "Checks if the given array is present and it is not empty (contains at least one element).", - "signature": "(xs?: object | undefined) => boolean", + "signature": "(xs?: object) => boolean", "examples": [ { "language": "javascript", diff --git a/object/any.md b/object/any.md index 72b50f52..01b2942c 100644 --- a/object/any.md +++ b/object/any.md @@ -6,6 +6,6 @@ Checks if the given array is present and it is not empty (contains at least one ```typescript -(xs?: object | undefined) => boolean +(xs?: object) => boolean ``` diff --git a/object/apply.json b/object/apply.json index 0adf0f74..261f0593 100644 --- a/object/apply.json +++ b/object/apply.json @@ -1,7 +1,7 @@ { "name": "apply", "description": "Applies the given parameters to the given dictionary of functions.", - "signature": "(\n fs: ((...xs: any[]) => any)[]\n) => (\n ...xs: any[]\n) => {\n [x: string]: any;\n [x: number]: any;\n}", + "signature": "(\n fs: ((...xs: any[]) => any)[]\n) => (...xs: any[]) => object", "examples": [ { "language": "javascript", diff --git a/object/apply.md b/object/apply.md index 2317952b..9188d303 100644 --- a/object/apply.md +++ b/object/apply.md @@ -8,11 +8,6 @@ Applies the given parameters to the given dictionary of functions. ```typescript ( fs: ((...xs: any[]) => any)[] -) => ( - ...xs: any[] -) => { - [x: string]: any; - [x: number]: any; -} +) => (...xs: any[]) => object ``` diff --git a/object/fromEntries.json b/object/fromEntries.json index 97f3e160..4c9e1192 100644 --- a/object/fromEntries.json +++ b/object/fromEntries.json @@ -1,7 +1,7 @@ { "name": "fromEntries", "description": "Creates an object from array of key value pairs (entries).", - "signature": "{\n (entries: Iterable): {\n [x: string]: T;\n [x: number]: T;\n };\n (entries: Iterable): any;\n}", + "signature": "(keyValuePairs: [string, any][]) => object", "examples": [ { "language": "javascript", diff --git a/object/fromEntries.md b/object/fromEntries.md index f57d18a4..6dd11534 100644 --- a/object/fromEntries.md +++ b/object/fromEntries.md @@ -6,12 +6,6 @@ Creates an object from array of key value pairs (entries). ```typescript -{ - (entries: Iterable): { - [x: string]: T; - [x: number]: T; - }; - (entries: Iterable): any; -} +(keyValuePairs: [string, any][]) => object ``` diff --git a/object/hasKey.json b/object/hasKey.json index e434e255..e0302ca0 100644 --- a/object/hasKey.json +++ b/object/hasKey.json @@ -1,7 +1,7 @@ { "name": "hasKey", "description": "Checks if given key is present in the object.", - "signature": "(key: string) => (xs?: any) => boolean", + "signature": "(key: string) => (xs?: any) => any", "examples": [ { "language": "javascript", diff --git a/object/hasKey.md b/object/hasKey.md index 91186ba7..fb89a043 100644 --- a/object/hasKey.md +++ b/object/hasKey.md @@ -6,6 +6,6 @@ Checks if given key is present in the object. ```typescript -(key: string) => (xs?: any) => boolean +(key: string) => (xs?: any) => any ``` diff --git a/object/none.json b/object/none.json index 1b583d27..88c0914f 100644 --- a/object/none.json +++ b/object/none.json @@ -1,7 +1,7 @@ { "name": "none", "description": "Checks if the given object is empty.", - "signature": "(xs?: object | undefined) => boolean", + "signature": "(xs?: object) => boolean", "examples": [ { "language": "javascript", diff --git a/object/none.md b/object/none.md index 0462eb2b..45bc7b3f 100644 --- a/object/none.md +++ b/object/none.md @@ -6,6 +6,6 @@ Checks if the given object is empty. ```typescript -(xs?: object | undefined) => boolean +(xs?: object) => boolean ``` diff --git a/query/README.md b/query/README.md index c3305c9b..2ab9105d 100644 --- a/query/README.md +++ b/query/README.md @@ -6,12 +6,7 @@ Parses a query string into an object. ```typescript -( - xs?: string -) => { - [x: string]: string | boolean; - [x: number]: string | boolean; -} +(xs?: string) => object ``` diff --git a/query/parse.json b/query/parse.json index 60cb1720..6463b774 100644 --- a/query/parse.json +++ b/query/parse.json @@ -1,7 +1,7 @@ { "name": "parse", "description": "Parses a query string into an object.", - "signature": "(\n xs?: string\n) => {\n [x: string]: string | boolean;\n [x: number]: string | boolean;\n}", + "signature": "(xs?: string) => object", "examples": [ { "language": "javascript", diff --git a/query/parse.md b/query/parse.md index 8e7b4cde..c5c300f5 100644 --- a/query/parse.md +++ b/query/parse.md @@ -6,11 +6,6 @@ Parses a query string into an object. ```typescript -( - xs?: string -) => { - [x: string]: string | boolean; - [x: number]: string | boolean; -} +(xs?: string) => object ``` diff --git a/string/README.md b/string/README.md index 111881ef..95fdeffe 100644 --- a/string/README.md +++ b/string/README.md @@ -86,7 +86,7 @@ Checks if the given string is present and is not empty or all whitespace. ```typescript -(x?: string | undefined) => boolean +(x?: string) => boolean ``` diff --git a/string/nonEmpty.json b/string/nonEmpty.json index 690c9a45..02c46172 100644 --- a/string/nonEmpty.json +++ b/string/nonEmpty.json @@ -1,7 +1,7 @@ { "name": "nonEmpty", "description": "Checks if the given string is present and is not empty or all whitespace.", - "signature": "(x?: string | undefined) => boolean", + "signature": "(x?: string) => boolean", "examples": [ { "language": "javascript", diff --git a/string/nonEmpty.md b/string/nonEmpty.md index c69b7d0c..691c8291 100644 --- a/string/nonEmpty.md +++ b/string/nonEmpty.md @@ -6,6 +6,6 @@ Checks if the given string is present and is not empty or all whitespace. ```typescript -(x?: string | undefined) => boolean +(x?: string) => boolean ``` diff --git a/web/README.md b/web/README.md index 33d6bba3..a20ace5e 100644 --- a/web/README.md +++ b/web/README.md @@ -41,10 +41,10 @@ Tests if the current event seems like an intent to open a new tab. Useful for cl metaKey, shiftKey }: { - button?: number | undefined; - ctrlKey?: boolean | undefined; - metaKey?: boolean | undefined; - shiftKey?: boolean | undefined; + button?: number; + ctrlKey?: boolean; + metaKey?: boolean; + shiftKey?: boolean; }) => boolean ``` diff --git a/web/events/README.md b/web/events/README.md index 3a8dfd6c..f487b478 100644 --- a/web/events/README.md +++ b/web/events/README.md @@ -27,10 +27,10 @@ Tests if the current event seems like an intent to open a new tab. Useful for cl metaKey, shiftKey }: { - button?: number | undefined; - ctrlKey?: boolean | undefined; - metaKey?: boolean | undefined; - shiftKey?: boolean | undefined; + button?: number; + ctrlKey?: boolean; + metaKey?: boolean; + shiftKey?: boolean; }) => boolean ``` diff --git a/web/events/openInNewTabIntent.json b/web/events/openInNewTabIntent.json index 735497e4..4e5b4791 100644 --- a/web/events/openInNewTabIntent.json +++ b/web/events/openInNewTabIntent.json @@ -1,7 +1,7 @@ { "name": "openInNewTabIntent", "description": "Tests if the current event seems like an intent to open a new tab. Useful for client-side navigation handling.", - "signature": "({\n button,\n ctrlKey,\n metaKey,\n shiftKey\n}: {\n button?: number | undefined;\n ctrlKey?: boolean | undefined;\n metaKey?: boolean | undefined;\n shiftKey?: boolean | undefined;\n}) => boolean", + "signature": "({\n button,\n ctrlKey,\n metaKey,\n shiftKey\n}: {\n button?: number;\n ctrlKey?: boolean;\n metaKey?: boolean;\n shiftKey?: boolean;\n}) => boolean", "examples": [ { "language": "javascript", diff --git a/web/events/openInNewTabIntent.md b/web/events/openInNewTabIntent.md index 48076f53..2e522bc7 100644 --- a/web/events/openInNewTabIntent.md +++ b/web/events/openInNewTabIntent.md @@ -12,10 +12,10 @@ Tests if the current event seems like an intent to open a new tab. Useful for cl metaKey, shiftKey }: { - button?: number | undefined; - ctrlKey?: boolean | undefined; - metaKey?: boolean | undefined; - shiftKey?: boolean | undefined; + button?: number; + ctrlKey?: boolean; + metaKey?: boolean; + shiftKey?: boolean; }) => boolean ```