{"id":22160392,"url":"https://github.com/rozek/javascript-interface-library","last_synced_at":"2026-02-13T15:00:10.918Z","repository":{"id":57279573,"uuid":"377800272","full_name":"rozek/javascript-interface-library","owner":"rozek","description":"various classification, validation and utility functions","archived":false,"fork":false,"pushed_at":"2024-09-28T09:37:43.000Z","size":386,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-11T21:35:13.671Z","etag":null,"topics":["input-validation","javascript","type-checking","typescript","utility-functions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rozek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-17T11:02:47.000Z","updated_at":"2024-09-28T09:37:46.000Z","dependencies_parsed_at":"2024-05-20T06:23:45.382Z","dependency_job_id":"e215f8b1-e7de-49f6-9524-97802510820f","html_url":"https://github.com/rozek/javascript-interface-library","commit_stats":{"total_commits":116,"total_committers":1,"mean_commits":116.0,"dds":0.0,"last_synced_commit":"ce9932c1f65fd866f16c4f54fc639aeb3cf351d0"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fjavascript-interface-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fjavascript-interface-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fjavascript-interface-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rozek%2Fjavascript-interface-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rozek","download_url":"https://codeload.github.com/rozek/javascript-interface-library/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227668795,"owners_count":17801513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["input-validation","javascript","type-checking","typescript","utility-functions"],"created_at":"2024-12-02T04:07:40.862Z","updated_at":"2026-02-13T15:00:05.888Z","avatar_url":"https://github.com/rozek.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# javascript-interface-library #\n\nvarious classification, validation and utility functions for JavaScript and TypeScript\n\nFrom time to time, it's necessary to classify and/or validate the values of user inputs, data read from input streams (like files or network connections) or arguments passed as part of a function call. While TypeScript type annotations already eliminate the need for many of these tests, there still exist lots of interfaces to the outer (non-TypeScript) world where value checking remains important.\n\nThese situations are, what the `javascript-interface-library` has been made for.\n\n**NPM users**: please consider the [Github README](https://github.com/rozek/javascript-interface-library/blob/main/README.md) for the latest description of this package (as updating the docs would otherwise always require a new NPM package version)\n\n\u003e Just a small note: if you like this module and plan to use it, consider \"starring\" this repository (you will find the \"Star\" button on the top right of this page), so that I know which of my repositories to take most care of.\n\n## Installation ##\n\n`javascript-interface-library` may be used as an ECMAScript module (ESM), a CommonJS or AMD module or from a global variable.\n\nYou may either install the package into your build environment using [NPM](https://docs.npmjs.com/) with the command\n\n```\nnpm install javascript-interface-library\n```\n\nor load the plain script file directly\n\n```html\n\u003cscript src=\"https://unpkg.com/javascript-interface-library\"\u003e\u003c/script\u003e\n```\n\n## Access ##\n\nHow to access the package depends on the type of module you prefer\n\n* ESM (or Svelte): `import { ValueIsListSatisfying, ValueIsOrdinal } from 'javascript-interface-library'`\n* CommonJS: `const JIL = require('javascript-interface-library')`\n* AMD: `require(['javascript-interface-library'], (JIL) =\u003e {...})`\n\nAlternatively, you may access the global variable `JIL` directly.\n\nNote for ECMAScript module users: all module functions and values are exported individually, thus allowing your bundler to perform some \"tree-shaking\" in order to include actually used functions or values (together with their dependencies) only.\n\n\n## Usage within Svelte ##\n\nFor Svelte, it is recommended to import the package in a module context. From then on, its exports may be used as usual:\n\n```html\n\u003cscript context=\"module\"\u003e\n  import { ValueIsListSatisfying, ValueIsOrdinal } from 'javascript-interface-library'\n\u003c/script\u003e\n\n\u003cscript\u003e\n  console.log(ValueIsListSatisfying(\n    [1,2,3,4], ValueIsOrdinal, 1,10\n  ))\n\u003c/script\u003e\n```\n\n## Usage as ECMAscript, CommonJS or AMD Module (or as a global Variable) ##\n\nLet's assume that you already \"required\" or \"imported\" (or simply loaded) the module according to your local environment. In that case, you may use it as follows:\n\n```javascript\nconsole.log(JIL.ValueIsListSatisfying(\n  [1,2,3,4], JIL.ValueIsOrdinal, 1,10\n))\n```\n\n## API Reference ##\n\nAs shown above, the individual functions and values may either be accessed directly (when used as an ESM) or by prefixing them with their namespace `JIL` (in all other cases). The following documentation lists all module contents without namespace prefix only, and the shown function signatures are those used by TypeScript.\n\n### Object Functions ###\n\nThe JavaScript `Object` class provides a few useful functions (or \"static methods\") for inspecting or converting a given object. Unfortunately, these functions are often used without prior checking whether the given target object actually inherits from the `Object` protoype or was built using `Object.create(null)` - and will fail whenever such a \"vanilla\" object is given.\n\n`JIL` therefore contains the following functions which mimic their counterparts from the `Object` class, but succeed even if the given target object is \"vanilla\".\n\n* **`Object_hasOwnProperty (Value:Object, PropertyName:string):boolean`**\u003cbr\u003ereturns `true` if the given `Value` contains a property with the name `PropertyName` as its own property - or `false` otherwise. This function mimics the JavaScript method [Object.hasOwnProperty](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty)\n* **`Object_isPrototypeOf (Value:Object, Candidate:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` exists in the prototype chain of a given `Candidate` - or `false` otherwise. This function mimics the JavaScript method [Object.isPrototypeOf](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf)\n* **`Object_propertyIsEnumerable (Value:Object, PropertyName:string):boolean`**\u003cbr\u003ereturns `true` if the given `Value` contains a property with the name `PropertyName` as its own property and that one is enumerable - or `false` otherwise. This function mimics the JavaScript method [Object.propertyIsEnumerable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/propertyIsEnumerable)\n* **`Object_toString (Value:Object):string`**\u003cbr\u003ereturns a string which represents the given `Value`. This function mimics the JavaScript method [Object.toString](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)\n* **`Object_toLocaleString (Value:Object):string`**\u003cbr\u003ereturns a locale-specific string which represents the given `Value`. This function mimics the JavaScript method [Object.toLocaleString](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toLocaleString)\n* **`Object_valueOf (Value:Object):any`**\u003cbr\u003ereturns the primitive value of the given `Value` object. This function mimics the JavaScript method [Object.valueOf](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/valueOf)\n\n### Value Classification Functions ###\n\nThe following functions check whether a given argument satisfies a certain constraint (e.g., belongs to a certain category) and return either `true` (if the constrain is met) or false otherwise.\n\n* **`ValueExists (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` exists, i.e., if it differs from both `null` and `undefined` - or `false` otherwise\n* **`ValueIsMissing (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is either `null` or `undefined` - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsBoolean (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is either a primitive boolean value or an instance of `Boolean` - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsNumber (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is either a primitive numeric value or an instance of `Number` - or `false` otherwise\n* **`ValueIsFiniteNumber (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a finite number, i.e. a number which is not `NaN` and whose value is greater than negative and smaller than positive infinity - or `false` otherwise\n* **`ValueIsNaN (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is `NaN` - or `false` otherwise\n* **`ValueIsNumberInRange (Value:any, minValue?:number, maxValue?:number, withMin:boolean = true, withMax:boolean = true):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a number whose value is within the range given by `minValue` and `maxValue` - or `false` otherwise. `minValue` is optional and defaults to negative infinity, `maxValue` is also optional but defaults to positive infinity. When `true`, `withMin` indicates that `Value` may also be *equal* to the lower end of the given range, otherwise it must just be *greater than* the lower limit. When `true`, `withMax` indicates that `Value` may also be *equal* to the upper end of the given range, otherwise it must just be *lower than* the upper limit\n* **`ValueIsInteger (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a whole number - or `false` otherwise\n* **`ValueIsIntegerInRange (Value:any, minValue?:number, maxValue?:number):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a whole number whose value is within the range given by `minValue` and `maxValue` - or `false` otherwise. `minValue` is optional and defaults to negative infinity, `maxValue` is also optional but defaults to positive infinity\n* **`ValueIsOrdinal (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a whole number greater than or equal to zero - or `false` otherwise\n* **`ValueIsCardinal (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a whole number greater than or equal to one - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsString (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is either a primitive literal value or an instance of `String` - or `false` otherwise\n* **`ValueIsEmptyString (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a string without any characters or with some content that consists of white-space characters only - or `false` otherwise\n* **`ValueIsNonEmptyString (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a string with some content that does not just consist of white-space characters - or `false` otherwise\n* **`ValueIsStringMatching (Value:any, Pattern:RegExp):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a string whose content matches the given regular expression `Pattern` - or `false` otherwise\n* **`ValueIsText (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a string containing \"ordinary\" text only (i.e., a string which lacks any kind of control characters except \\\\n or \\\\r) - or `false` otherwise\n* **`ValueIsTextline (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a string containing a single line of \"ordinary\" text only (i.e., a string which lacks any kind of control characters) - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsFunction (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a JavaScript function - or `false` otherwise\n* **`ValueIsAnonymousFunction (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is an anonymous JavaScript function (i.e., a function without a `name` property)  - or `false` otherwise\n* **`ValueIsNamedFunction (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a \"named\" JavaScript function (i.e., a function with a non-empty `name` property) - or `false` otherwise\n* **`ValueIsNativeFunction (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a native JavaScript function - or `false` otherwise\n* **`ValueIsScriptedFunction (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a scripted JavaScript function - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsObject (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a JavaScript object (and not `null`) - or `false` otherwise\n* **`ValueIsPlainObject (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a JavaScript object (different from `null`) which directly inherits from `Object` (such as a Javascript object literal) - or `false` otherwise\n* **`ValueIsVanillaObject (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a JavaScript object which has been built using `Object.create(null)` - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsArray (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is an `Array` instance - or `false` otherwise. If given, `minLength` specifies the minimal required list length and `maxLength` specifies the maximal allowed list length\n* **`ValueIsList (Value:any, minLength?:number, maxLength?:number):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a \"dense\" JavaScript array (i.e., an array whose indices 0...n-1 all exist, where n is the `length` of the given array) - or `false` otherwise\n* **`ValueIsListSatisfying (Value:any, Validator:Function, minLength?:number, maxLength?:number):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a \"dense\" JavaScript array, whose elements all pass the given `Validator` - or `false` otherwise. `Validator` is a function which receives a list element as its sole argument and returns `true` if the given element is \"valid\" or `false` otherwise. If given, `minLength` specifies the minimal required list length and `maxLength` specifies the maximal allowed list length\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsInstanceOf (Value:any, Constructor:Function):boolean`**\u003cbr\u003ereturns `true` if the given `Value` was constructed using the given `Constructor` function - or `false` otherwise\n* **`ValueInheritsFrom (Value:any, Prototype:Object):boolean`**\u003cbr\u003ereturns `true` if `Prototype` exists in the prototype chain of the given `Value` - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsDate (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a `Date` instance - or `false` otherwise\n* **`ValueIsError (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is an `Error` instance  - or `false` otherwise\n* **`ValueIsPromise (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a \"Promise\", i.e., an object with a property named `then` which contains a function - or `false` otherwise\n* **`ValueIsRegExp (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a `RegExp` instance - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsOneOf (Value:any, ValueList:any[]):boolean`**\u003cbr\u003ereturns `true` if the given `Value` equals (at least) one of the items found in the given `ValueList` - or `false` otherwise. Equality is checked using the JavaScript `===` operator\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValueIsColor (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a string containing a syntactically valid CSS color specification - or `false` otherwise\n* **`ValueIsEMailAddress (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a string containing a syntactically valid EMail address - or `false` otherwise\n* **`ValueIsURL (Value:any):boolean`**\u003cbr\u003ereturns `true` if the given `Value` is a string containing a syntactically valid URL - or `false` otherwise\n\n### Argument Validation Functions ###\n\nThe following functions check whether a given argument satisfies a certain constraint (e.g., belongs to a certain category) and either return the given argument (sometimes after some normalization), if the constrain is met, or throw an error otherwise.\n\nUnless stated otherwise, these functions exist in four different \"flavours\", as indicated by their name prefixes:\n\n* `allowXXX`\u003cbr\u003evalidates the given argument and returns it, if it is either missing (i.e., equals `null` or `undefined`) or meets the condition defined for `XXX` - or throws an exception otherwise\n* `allwedXXX`\u003cbr\u003esynonym for `allowXXX`, looks better when used as an expression\n* `expectXXX`\u003cbr\u003evalidates the given argument and returns it, if it exists (i.e., differs both from `null` and `undefined`) and meets the condition defined for `XXX` - or throws an exception otherwise  \n* `expectedXXX`\u003cbr\u003esynonym for `expectXXX`, looks better when used as an expression\n\nFor the sake of clarity, however, only the first \"flavour\" (namely `allowXXX`) is shown in the list below (provided that this flavour actually exists).\n\n* **`expectValue (Description:string, Argument:any):any`**\u003cbr\u003echecks if the given `Argument` exists (i.e., if it differs from both `null` and `undefined`). If this is the case, the function returns the given `Argument`, otherwise an error with the message `\"no ${Description} given\"` is thrown, which uses the given `Description` argument. Please note: this function does not exist in the flavours `allowXXX` or `allowedXXX`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowBoolean (Description:string, Argument:any):boolean|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is either a primitive boolean value or an instance of `Boolean`. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error with the message `\"the given ${Description} is no valid boolean value\"` is thrown, which uses the given `Description`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowNumber (Description:string, Argument:any):number|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is either a primitive numeric value or an instance of `Number`. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error with the message `\"the given ${Description} is no valid numeric value\"` is thrown, which uses the given `Description`\n* **`allowFiniteNumber (Description:string, Argument:any):number|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a finite number, i.e. a number which is not `NaN` and whose value is greater than negative and smaller than positive infinity. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowNaN (Description:string, Argument:any):number|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is `NaN`. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowNumberInRange (Description:string, Argument:any, minValue?:number, maxValue?:number, withMin?:boolean, withMax?:boolean):number|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a number whose value is within the range given by `minValue` and `maxValue`. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`. `minValue` is optional and defaults to negative infinity, `maxValue` is also optional but defaults to positive infinity. When true, `withMin` indicates that `Value` may also be *equal* to the lower end of the given range, otherwise it must just be *greater than* the lower limit. When true, `withMax` indicates that `Value` may also be *equal* to the upper end of the given range, otherwise it must just be *lower than* the upper limit\n* **`allowInteger (Description:string, Argument:any):number|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a whole number. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowIntegerInRange (Description:string, Argument:any, minValue?:number, maxValue?:number):number|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a whole number whose value is within the range given by `minValue` and `maxValue`. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`. `minValue` is optional and defaults to negative infinity, `maxValue` is also optional but defaults to positive infinity\n* **`allowOrdinal (Description:string, Argument:any):number|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a whole number greater than or equal to zero. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowCardinal (Description:string, Argument:any):number|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a whole number greater than or equal to one. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowString (Description:string, Argument:any):string|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is either a primitive literal value or an instance of `String`. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error with the message `\"the given ${Description} is no valid literal string\"` is thrown, which uses the given `Description`\n* **`allowNonEmptyString (Description:string, Argument:any):string|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a string with some content that does not just consist of white-space characters. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowStringMatching (Description:string, Argument:any, Pattern:RegExp):string|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a string whose content matches the given regular expression `Pattern`. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowText (Description:string, Argument:any):string|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a string containing \"ordinary\" text only (i.e., a string which lacks any kind of control characters except \\\\n or \\\\r). If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowTextline (Description:string, Argument:any):string|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a string containing a single line of \"ordinary\" text only (i.e., a string which lacks any kind of control characters). If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowFunction (Description:string, Argument:any):Function|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a JavaScript function. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowAnonymousFunction (Description:string, Argument:any):Function|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is an anonymous JavaScript function (i.e., a function without a name property). If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowNamedFunction (Description:string, Argument:any):Function|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a \"named\" JavaScript function (i.e., a function with a non-empty `name` property). If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowNativeFunction (Description:string, Argument:any):Function|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a native JavaScript function. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowScriptedFunction (Description:string, Argument:any):Function|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a scripted JavaScript function. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowObject (Description:string, Argument:any):any|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a JavaScript object (and not `null`). If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowPlainObject (Description:string, Argument:any):any|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a JavaScript object (different from `null`) which directly inherits from `Object` (such as a Javascript object literal). If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowVanillaObject (Description:string, Argument:any):any|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a JavaScript object which has been built using `Object.create(null)`. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowArray (Description:string, Argument:any):any[]|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is an `Array` instance. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowList (Description:string, Argument:any, Expectation?:string,minLength?:number, maxLength?:number):any[]|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a \"dense\" JavaScript array (i.e., an array whose indices 0...n-1 all exist, where n is the length of the given array). If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`. If given, `minLength` specifies the minimal required list length and `maxLength` specifies the maximal allowed list length\n* **`allowListSatisfying (Description:string, Argument:any, Validator:(Value:any) =\u003e boolean,Expectation?:string, minLength?:number, maxLength?:number):any[]|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a \"dense\" JavaScript array, whose elements all pass the given `Validator`. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`. `Validator` is a function which receives a list element as its sole argument and returns `true` if the given element is \"valid\" or `false` otherwise. If given, `minLength` specifies the minimal required list length and `maxLength` specifies the maximal allowed list length\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowInstanceOf (Description:string, Argument:any, constructor:Function, Expectation:string):any|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) was constructed using the given `Constructor` function. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowValueInheritingFrom (Description:string, Argument:any, prototype:any, Expectation:string):any|null|undefined`**\u003cbr\u003echecks if  `Prototype` exists in the prototype chain of the given `Argument` (if that exists). If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowDate (Description:string, Argument:any):Date|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a `Date` instance. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowError (Description:string, Argument:any):Error|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is an `Error` instance. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowPromise (Description:string, Argument:any):any|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a \"Promise\", i.e., an object with a property named `then` which contains a function. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowRegExp (Description:string, Argument:any):RegExp|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a `RegExp` instance. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowOneOf (Description:string, Argument:any, ValueList:any[]):any|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) equals (at least) one of the items found in the given `ValueList`. If this is the case (or `Argument` is missing), the function returns the given `Argument`, otherwise an error is thrown whose message contains the given `Description`. Equality is checked using the JavaScript `===` operator\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`allowColor (Description:string, Argument:any):string|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a string containing a syntactically valid CSS color specification. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowEMailAddress (Description:string, Argument:any):string|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a string containing a syntactically valid EMail address. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n* **`allowURL (Description:string, Argument:any):string|null|undefined`**\u003cbr\u003echecks if the given `Argument` (if it exists) is a string containing a syntactically valid URL. If this is the case (or `Argument` is missing), the function returns the primitive value of the given `Argument`, otherwise an error is thrown whose message contains the given `Description`\n\n### Utility Functions ###\n\n* **`throwableError (Message:string):Error`**\u003cbr\u003ethis function has been provided in order to simplify the construction of \"named\" `Error` instances: if the given `Message` starts with a JavaScript identifier followed by a colon, identifier and colon are stripped apart and the identifier is used as the `name` property of a newly constructed `Error` instance for the remaining part of `Message`. Otherwise, this function is equivalent to `new Error(Message)`\n* **`throwError (Message:string):never`**\u003cbr\u003ethis function has been provided in order to simplify throwing \"named\" `Error` instances: if the given `Message` starts with a JavaScript identifier followed by a colon, identifier and colon are stripped apart and the identifier is used as the `name` property of a newly constructed `Error` instance for the remaining part of `Message`. Otherwise, this function is equivalent to `throw new Error(Message)` \u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ObjectMergedWith (TargetObject:object, ...otherObjectList:object[]):object`**\u003cbr\u003e`Object.assign` can not be used to copy properties with getters and setters from one object into another - this is what `ObjectMergedWith` is good for: it copies the descriptors of all *own* properties from any object found in `otherObjectList` into the given `TargetObject` and also returns that object as its function result. Any  descriptor already existing for a given property in `TargetObject` will be overwritten\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`constrained (Value:number, Minimum:number = -Infinity, Maximum:number = Infinity):number`**\u003cbr\u003elimits the given `Value` to the range specified by `Minimum` and `Maximum` - i.e., the function returns `Minimum` if `Value` is less than (or equal to) `Minimum`, `Maximum` if `Value` is greater than (or equal to) `Maximum`, or `Value` itself otherwise. `Minimum` and `Maximum` are optional and default to `-Infinity` or `+Infinity`, resp.\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`escaped (Text:string):string`**\u003cbr\u003ereturns a copy of the given `Text` in which all control characters have been replaced by their corresponding escape sequences\n* **`unescaped (Text:string):string`**\u003cbr\u003ereturns a copy of the given `Text` in which all character escape sequences have been replaced by their corresponding (control) characters\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`quotable (Text:string, Quote:'\"' | \"'\" = '\"'):string`**\u003cbr\u003ereturns a copy of the given `Text` in which all control characters and `Quote`s have been replaced by their corresponding escape sequences. The outcome of this function may, f.e., used to construct literal values in JSON files. `Quote` is optional and defaults to the double-quotes character\n* **`quoted (Text:string, Quote:'\"' | \"'\" = '\"'):string`**\u003cbr\u003ereturns a copy of the given `Text` (embedded within a pair of `Quote`s) in which all control characters and `Quote`s have been replaced by their corresponding escape sequences. The outcome of this function may, f.e., used to construct literal values in JSON files. `Quote` is optional and defaults to the double-quotes character\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`HTMLsafe (Argument:string, EOLReplacement?:string):string`**\u003cbr\u003ereturns a copy of the given `Argument` in which all control characters (except `\\n`) and characters with a special meaning for HTML have been replaced by their corresponding HTML entities. Any linefeed characters (`\\n`) will be replaced by the given `EOLReplacement` string - specification of `EOLReplacement` is optional and defaults to `\u003cbr/\u003e`\n* **`MarkDownSafe (Argument:string, EOLReplacement?:string):string`**\u003cbr\u003ereturns a copy of the given `Argument` in which all control characters (except `\\n`) and characters with a special meaning for (HTML and) Markdown have been replaced by their corresponding HTML entities. Any linefeed characters (`\\n`) will be replaced by the given `EOLReplacement` string - specification of `EOLReplacement` is optional and defaults to `\u003cbr/\u003e`\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValuesDiffer (thisValue:any, otherValue:any, Mode?:'by-value'|'by-reference'|undefined):boolean`**\u003cbr\u003ereturns `true` if `thisValue` differs from `otherValue` - or `false` otherwise. Equality is checked by inspection, i.e., `null`, `undefined`, booleans, strings and functions are checked using the JavaScript `===` operator, comparison of numbers also takes care of `NaN` and a potential deviation by `Number.EPSILON` and objects or arrays are (by default) compared element by element. If the optional `Mode` is set to `by-reference`, Objects are always compared by reference, if set to `by-value`, instances of `Boolean`, `Number` and `String` are always compared by their primitive value\n* **`ValuesAreEqual (thisValue:any, otherValue:any, Mode?:'by-value'|'by-reference'|undefined):boolean`**\u003cbr\u003ereturns `true` if `thisValue` equals to `otherValue` - or `false` otherwise. Equality is checked by inspection, i.e., `null`, `undefined`, booleans, strings and functions are checked using the JavaScript `===` operator, comparison of numbers also takes care of `NaN` and a potential deviation by `Number.EPSILON` and objects or arrays are (by default) compared element by element. If the optional `Mode` is set to `by-reference`, Objects are always compared by reference, if set to `by-value`, instances of `Boolean`, `Number` and `String` are always compared by their primitive value\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ObjectIsEmpty (Candidate:any):boolean`**\u003cbr\u003ereturns true if the given `Candidate` is an empty object (i.e., an object without any *own* properties) - or `false` otherwise\n* **`ObjectIsNotEmpty (Candidate:any):boolean`**\u003cbr\u003ereturns true if the given `Candidate` is a non-empty empty object (i.e., an object with at least one *own* property) - or `false` otherwise\n* **`StringIsEmpty (Candidate:string):boolean`**\u003cbr\u003ereturns true if the given `Candidate` is an empty string (i.e., a string which either contains no characters at all or only whitespace characters) - or `false` otherwise\n* **`StringIsNotEmpty (Candidate:string):boolean`**\u003cbr\u003ereturns true if the given `Candidate` is a non-empty string (i.e., a string which contains one or more characters and not all of them are whitespace characters) - or `false` otherwise\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`ValidatorForClassifier (Classifier:(Value:any) =\u003e boolean, NilIsAcceptable:boolean, Expectation:string):Function`**\u003cbr\u003ethis function is used internally to construct many of the offered argument validation functions: it returns a new function which takes a `Description` and an `Argument`, uses the given `Classifier` to check if `Argument` belongs to the expected category of values and - if it does - returns the primitive value of the given `Argument`. Otherwise, an error message is constructed, which includes the given `Description` and complains about the given value not being a \"valid ${Expectation}\" - i.e., `Expectation` should describe the expected kind of argument. If set to `true`, `NilIsAcceptable` indicates that `Argument` may be missing (i.e., `null` or `undefined`), otherwise the given `Argument` is mandatory.\u003cbr\u003e\u0026nbsp;\u003cbr\u003e**Important Note**: if you plan to develop a library which may be \"tree-shaked\" by application bundlers (such as WebPack and Rollup) and export functions built with `ValidatorForClassifier`, you should mark all invocations of `ValidatorForClassifier` as \"free of side-effects\" by prepending them with `/*#__PURE__*/` - otherwise those invocations will remain in the bundled code even if you don't use the corresponding exports\n* **`validatedArgument (Description:string, Argument:any, ValueIsValid:(Value:any) =\u003e boolean,NilIsAcceptable:boolean, Expectation:string):any|null|undefined`**\u003cbr\u003ethis function is used internally to actually validate a given `Argument` and throw an `Error` with a message containing the given `Description`, if not. `ValueIsValid` is the function used check `Argument` and should return `true` if `Argument` is \"valid\" or `false` if not. If set to `true`, `NilIsAcceptable` indicates that `Argument` may be missing (i.e., `null` or `undefined`), otherwise the given `Argument` is mandatory. If validation fails, an error message is constructed, which includes the given `Description` and complains about the given value not being a \"valid ${Expectation}\" - i.e., `Expectation` should describe the expected kind of argument\u003cbr\u003e\u0026nbsp;\u003cbr\u003e\n* **`FunctionWithName (originalFunction:Function, desiredName:string|String):Function`**\u003cbr\u003ethis function is used internally to convert an anonymous function `originalFunction` into a named one - either by setting the `desiredName` for the existing function or by wrapping it into a new function with that name\n\n### Color Utilities ###\n\n* **`ColorSet`**\u003cbr\u003eis an object, whose keys are the names of all colors known by (and built into) a web browser and the corresponding values are the RGBA specifications of these colors\n* **`HexColor (Color:string):string`**\u003cbr\u003econverts a given `Color` string (which must be a valid CSS color specification) into the long hexadecimal format (`#rrggbbaa`)\n* **`shortHexColor (Color:string):string`**\u003cbr\u003econverts a given `Color` string (which must be a valid CSS color specification) into the short hexadecimal format (`#rrggbb`) - such a format must be used for HTML input elements of type \"color\"\n* **`RGBAColor (Color:string):string`**\u003cbr\u003econverts a given `Color` string (which must be a valid CSS color specification) into the RGBA format (`rgba(r,g,b,a)`)\n\n## Build Instructions ##\n\nYou may easily build this package yourself.\n\nJust install [NPM](https://docs.npmjs.com/) according to the instructions for your platform and follow these steps:\n\n1. either clone this repository using [git](https://git-scm.com/) or [download a ZIP archive](https://github.com/rozek/javascript-interface-library/archive/refs/heads/main.zip) with its contents to your disk and unpack it there \n2. open a shell and navigate to the root directory of this repository\n3. run `npm install` in order to install the complete build environment\n4. execute `npm run build` to create a new build\n\nIf you made some changes to the source code, you may also try\n\n```\nnpm run agadoo\n```\n\nin order to check if the result is still tree-shakable.\n\nYou may also look into the author's [build-configuration-study](https://github.com/rozek/build-configuration-study) for a general description of his build environment.\n\n## License ##\n\n[MIT License](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frozek%2Fjavascript-interface-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frozek%2Fjavascript-interface-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frozek%2Fjavascript-interface-library/lists"}