This repository has been archived by the owner on Dec 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
811 additions
and
323 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { getTimestamp } from './utilities/datetime'; | ||
import { isServer, isClient } from './utilities/platform'; | ||
import { getUrlParameters, getUrlParameterByName, replaceUrlParameter } from './utilities/url'; | ||
import { decodeUri, encodeUri } from './utilities/uri'; | ||
import { removeString, isArray, includes, find, flat } from './utilities/array'; | ||
import { filterAlphaNumericPlus, capitaliseFirstLetter, stringContains, getSubstringIndex, replacePlaceholders } from './utilities/string'; | ||
import { generateUUID } from './utilities/uuid'; | ||
import { removeElements } from './utilities/html'; | ||
import { log } from './utilities/log'; | ||
import { sleep } from './utilities/helper'; | ||
import { randomInteger } from './utilities/random'; | ||
declare const version = "1.0.0"; | ||
export { version, getTimestamp, isServer, isClient, getUrlParameters, getUrlParameterByName, replaceUrlParameter, decodeUri, encodeUri, removeString, isArray, includes, find, flat, filterAlphaNumericPlus, capitaliseFirstLetter, stringContains, getSubstringIndex, replacePlaceholders, generateUUID, removeElements, log, sleep, randomInteger }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* finds "removeMe" and removes it from the array | ||
* @param array | ||
* @param removeMe | ||
*/ | ||
declare const removeString: (myArray: string[], removeMe: string) => string[]; | ||
/** | ||
* is array with polyfill for older browsers | ||
* @param input | ||
*/ | ||
declare const isArray: (input: unknown) => boolean; | ||
declare global { | ||
interface Array<T> { | ||
includes(valueToFind: string, fromIndex?: number): boolean; | ||
} | ||
} | ||
/** | ||
* finds "toFind" in an array, starting at an optional index | ||
* @param inputArray | ||
* @param toFind | ||
* @param fromIndex | ||
*/ | ||
declare const includes: (inputArray: [], toFind: string, fromIndex?: number) => boolean; | ||
/** | ||
* | ||
* @param inputArray | ||
* @param predicate | ||
* @param args | ||
*/ | ||
declare const find: (inputArray: [], predicate: (this: void, value: never, index: number, obj: never[]) => value is never, args?: any) => never | undefined; | ||
declare global { | ||
interface Array<T> { | ||
flat(depth: number): []; | ||
} | ||
} | ||
/** | ||
* array flat polyfill, if depth is unknow set it to "Infinity" | ||
* @param inputArray | ||
* @param depth | ||
*/ | ||
declare const flat: (inputArray: [], depth?: number) => []; | ||
export { removeString, isArray, includes, find, flat }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* returns the timestamp for any date or for now(), also works with browsers that dont support es5 Date.now | ||
* @param dateString | ||
*/ | ||
declare const getTimestamp: (dateString?: string | number) => number; | ||
export { getTimestamp }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* pauses your script for a given time, returns a promise that you can use to do so | ||
* @param ms | ||
*/ | ||
declare const sleep: (ms: number) => Promise<void>; | ||
export { sleep }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* extracts html elements (and their content) from strings | ||
* @param text | ||
* @param removeTextBetweenTags | ||
*/ | ||
declare const removeElements: (text: string, removeTextBetweenTags: boolean) => string; | ||
export { removeElements }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* log messages | ||
* @param args | ||
*/ | ||
declare const log: (...args: unknown[]) => void; | ||
export { log }; |
8 changes: 8 additions & 0 deletions
8
dist/@types/chrisweb-utilities/utilities/log/adapters/file.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* nodejs logging to file | ||
* @param logObjects | ||
* @param logObjectsLength | ||
* @param logFontColor | ||
*/ | ||
declare const fileLog: (logObjects: unknown, logObjectsLength: number, logFontColor: string) => void; | ||
export { fileLog }; |
18 changes: 18 additions & 0 deletions
18
dist/@types/chrisweb-utilities/utilities/log/adapters/html.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* html log | ||
* create a div an insert the messages in div | ||
* can be usefull on mobile if no other console is available | ||
* @param logObjects | ||
* @param logObjectsLength | ||
* @param logFontColor | ||
* @param logBackgroundColor | ||
*/ | ||
declare const htmlLog: (logObjects: string[], logObjectsLength: number, logFontColor: string, logBackgroundColor: string) => void; | ||
/** | ||
* extracts html elements (and their content) from strings | ||
* @param rawText | ||
* @param extendedEscape | ||
* @param myEscapeList | ||
*/ | ||
declare const safeUnescape: (rawText: string, extendedEscape: boolean, myEscapeList: string[]) => string; | ||
export { htmlLog, safeUnescape }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* does the script run on the server | ||
*/ | ||
declare const isServer: () => boolean; | ||
/** | ||
* does the script run in a client | ||
*/ | ||
declare const isClient: () => boolean; | ||
export { isServer, isClient }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* returns a random integer that lies between min (included) and max (included) | ||
* @param min | ||
* @param max | ||
*/ | ||
declare const randomInteger: (min?: number, max?: number) => number; | ||
export { randomInteger }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* filters a string | ||
* removes everything that is a not an alpha or numeric character, plus | ||
* the characters if any got specified as second argument | ||
* @param inputString | ||
* @param specialCharacters | ||
*/ | ||
declare const filterAlphaNumericPlus: (inputString: string, specialCharacters: string) => string | boolean; | ||
/** | ||
* capitalise first letter of a string | ||
* @param inputString | ||
*/ | ||
declare const capitaliseFirstLetter: (inputString: string) => string; | ||
/** | ||
* does a string contain another string | ||
* @param inputString | ||
* @param contains | ||
*/ | ||
declare const stringContains: (inputString: string, contains: string) => boolean; | ||
/** | ||
* get the index of a substring in a string with optional nth time it occurs | ||
* @param inputString | ||
* @param substring | ||
* @param nthTime | ||
*/ | ||
declare const getSubstringIndex: (inputString: string, substring: string, nthTime: number) => number; | ||
/** | ||
* replace the placeholder(s) with some value | ||
* @param input | ||
* @param replacements | ||
*/ | ||
declare const replacePlaceholders: (input: string, replacements: string) => string; | ||
export { filterAlphaNumericPlus, capitaliseFirstLetter, stringContains, getSubstringIndex, replacePlaceholders }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* decode uri | ||
* @param inputString | ||
*/ | ||
declare const decodeUri: (inputString: string) => string; | ||
/** | ||
* encode uri | ||
* @param inputString | ||
*/ | ||
declare const encodeUri: (inputString: string) => string; | ||
export { decodeUri, encodeUri }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* get url parameters | ||
* @param query | ||
*/ | ||
declare const getUrlParameters: (query?: string) => { | ||
[s: string]: string; | ||
}; | ||
/** | ||
* URL utility to get a parameter by name from an URL | ||
* @param name | ||
* @param url | ||
*/ | ||
declare const getUrlParameterByName: (name: string, url: string) => string; | ||
/** | ||
* URL utility to replace a given parameter | ||
* @param url | ||
* @param paramName | ||
* @param paramValue | ||
*/ | ||
declare const replaceUrlParameter: (url: string, paramName: string, paramValue: string | number) => string; | ||
export { getUrlParameters, getUrlParameterByName, replaceUrlParameter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/** | ||
* returns a universally unique identifier | ||
*/ | ||
declare const generateUUID: () => string; | ||
export { generateUUID }; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.