Download
A helper JavaScript library with useful functions and polyfills and zero dependencies.
Latest version: 6.4.0
Date: 2025-11-06T18:08:50.125Z
Tested on these environments:
- Windows Firefox
- Windows Chrome
- Windows Edge
- iOS Safari
- iOS Firefox
- iOS Chrome
- iOS Edge
- Android Firefox
- Android Chrome
- Android Samsung Internet
- Android Edge
- Node.js (latest current, not LTS)
- Deno (latest current, not LTS)
The functions are available in the celestra and/or CEL object or any function can be imported.
| version | page link |
| Stable repository | https://github.com/Serrin/Celestra |
| Beta repository | https://github.com/Serrin/Celestra-beta |
| Edition | Javascript or documentation | Typescript |
| Browser module | celestra.browser.js | celestra.browser.ts |
| Node.js and Deno module | celestra.node.mjs | celestra.node.mts |
| Celestra Unit Tester (CUT) | unittest.html | |
| Celestra cheatsheet |
celestra-cheatsheet.odt
celestra-cheatsheet.pdf |
|
| JavaScript cheatsheet |
js-cheatsheet.odt
js-cheatsheet.pdf |
|
| Version history | CHANGELOG.md | |
| Removed polyfills (developer) | celestra-polyfills.dev.js | |
| Removed polyfills (minified) | celestra-polyfills.min.js | |
| RPG dice roller | testgame.html |
How to import the browser edition
<script type="module">
// import the defaultExport object
import defaultExport from "./celestra.browser.js";
globalThis.celestra = defaultExport;
globalThis.CEL = defaultExport;
</script>
<script type="module">
// import with default with name
import { default as celestra } from "./celestra.browser.js";
globalThis.celestra = celestra;
globalThis.CEL = celestra;
</script>
<script type="module">
// import all into a new celestra object
import * as celestra from "./celestra.browser.js";
globalThis.celestra = celestra;
globalThis.CEL = celestra;
</script>
<script type="module">
// import some functions
import { first, map } from "./celestra.browser.js";
globalThis.first = first;
globalThis.map = map;
</script>
<script type="module">
// dynamic import
const celestra = await import("./celestra.browser.js");
globalThis.celestra = celestra;
globalThis.CEL = celestra;
</script>
How to import the Node.js edition
// import the defaultExport object
import defaultExport from "./celestra.nodejs.mjs";
globalThis.celestra = defaultExport;
globalThis.CEL = defaultExport;
// import with default with name
import { default as celestra } from "./celestra.nodejs.mjs";
globalThis.celestra = celestra;
globalThis.CEL = celestra;
// import all into a new celestra object
import * as celestra from "./celestra.nodejs.mjs";
globalThis.celestra = celestra;
globalThis.CEL = celestra;
// import some functions
import { first, map } from "./celestra.nodejs.mjs";
globalThis.first = first;
globalThis.map = map;
// dynamic import
const celestra = await import("./celestra.node.mjs");
globalThis.celestra = celestra;
globalThis.CEL = celestra;
Removed functions in the Node.js edition
| API | Function |
| DOM API | qsa();qs();domReady();domClear();domCreate();domToElement();domGetCSS();domSetCSS();domFadeIn();domFadeOut();domFadeToggle();domShow();domHide();domToggle();domIsHidden();domScrollToTop();domScrollToBottom();domScrollToElement();domSiblings();domSiblingsPrev();domSiblingsLeft();domSiblingsNext();domSiblingsRight();domGetCSSVar();domSetCSSVar();importScript();importStyle();setFullscreenOn();setFullscreenOn();setFullscreenOff();getFullscreen();form2array(form);form2string(form);getDoNotTrack();getLocation();createFile(); |
| Cookie API | getCookie();hasCookie();setCookie();removeCookie();clearCookies(); |
Celestra v3.0.0 (Hera) changes
- Only modern browsers (ES6+) are supported. The Internet Explorer 11 and W10M Edge have been removed from the supported browsers.
- If you would like to use Celestra with older browsers, then you can download the latest v2.x version here: https://github.com/Serrin/Celestra/releases
- The library sources have been merged and all of the ES6E functions are available in the celestra.dev.js and celestra.min.js
- Many functions have been deprecated or removed.
Celestra v3.6.0 (Galactica) changes
- CommonJS and AMD module compatibility have been removed.
- In the ESM (ECMAScript 6 module) edition only the whole celestra object is exported as default export and as standalone object.
- Many functions have been deprecated or removed.
Celestra v5.0.0 (Defiant) changes
- The underscore
_short object name has been changed toCELto avoid the compatibility issues.
Celestra v5.5.0 changes
- The Math functions are available in the main code files (dev, min, esm) instead of the Math plugins.
Celestra v5.6.0 (Razorback) changes
- 21 polyfills have been removed.
Celestra v5.7.0 (Nostromo) changes
- The module edition (celestra.esm.js) import has been changed.
- Added Assert API v3 and the old assert functions have been removed.
- The
getText();andgetJson();functions have been modified to standalone function.
Celestra v5.8.0 (Uhura) changes
- 50 functions have been removed.
Celestra v5.9.0 (Final five) changes
- 12 functions and a polyfill have been removed.
Celestra v6.0.0 (David) changes
- The Node.js and Deno support has been added.
Celestra v6.1.0 (Sulaco) changes
- Please read in the documentation about the new files and import methods for the browser edition!
- The celestra.dev.js has been replaced with the celestra.browser.ts.
- The celestra.min.js has been replaced with the celestra.browser.js.
- The celestra.node.mjs has been remained and added the celestra.node.mts.
- The
isNil();function has been renamed toisNullish();. - The
assertIsNil();function has been renamed toassertIsNullish();. - The
assertIsNotNil();function has been renamed toassertIsNotNullish();. - The
type();function has been renamed totypeOf();. - The
celestra.noConflict();function has been removed. - Some deprecated functions have been removed.
Celestra v6.3.0 (Bishop) changes
- The Legacy AJAX API has been removed.
- The Legacy Assertion API (Assert API v3) has been removed.
Functions
Stabilities
- Stability: 0 - Removed.
- Stability: 1 - Deprecated and will be removed.
- Stability: 2 - Deprecated.
- Stability: 3 - Legacy and can get only fixes.
- Stability: 4 - Stable.
Removed and Deprecated: Don't use these in production.
Core API
| Name | Description |
noConflict(); |
Stability: 0 - Removed in v6.1.0 Restore the previous Tip: You can make a new alias without this function too. Example: In the ESM edition only returns the celestra object. |
VERSION; |
Stability: 4 - Stable. The library version. |
BASE16; |
Stability: 4 - Stable."0123456789ABCDEF"Can be used with the ID generator functions. |
BASE32; |
Stability: 4 - Stable."234567ABCDEFGHIJKLMNOPQRSTUVWXYZ"Can be used with the ID generator functions. |
BASE36; |
Stability: 4 - Stable."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"Can be used with the ID generator functions. |
BASE58; |
Stability: 4 - Stable."123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"Can be used with the ID generator functions. |
BASE62; |
Stability: 4 - Stable."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"Can be used with the ID generator functions. |
WORDSAFEALPHABET; |
Stability: 4 - Stable."23456789CFGHJMPQRVWXcfghjmpqvwx"Can be used with the ID generator functions. |
assert(condition [, message | error]); |
Stability: 4 - Stable. This function throws an error with the message if the condition is falsy. The message parameter is optional. |
assoc(object, key, value); |
Stability: 4 - Stable. Clone the original object (immutably) and return this new object with original keys and values and the given key and value. |
asyncConstant(value); |
Stability: 4 - Stable. This function returns an async function, which returns a promise with the given value. |
asyncIdentity(value); |
Stability: 4 - Stable. This async function returns a promise with the given value. |
asyncF(); |
Stability: 4 - Stable. This async function returns a promise with false value. |
asyncNoop(); |
Stability: 4 - Stable. This function does nothing and returns a resolved promise. |
asyncT(); |
Stability: 4 - Stable. This async function returns a promise with true value. |
bind(function,context); |
Stability: 4 - Stable. Returns a function that is bound to a context. Both of the parameters are mandatory. |
compose(function1 [, functionN]); |
Stability: 4 - Stable. Compose functions right to left. At least one function parameter is mandatory. |
constant(value); |
Stability: 4 - Stable. A one time assignment function to create a constant value in ES5. This returns a function, which returns the given value. (In math: f(x)=x) |
createPolyfillMethod(object, property, value); |
Stability: 4 - Stable. This function creates a writable, configurable and non-enumerable property with the given value in the object if the property doesn't exist in the object. The return value boolean and checks that the creating of the method was successful. Example: CEL.createPolyfillMethod(Array.prototype, "at", function(...){...});
|
createPolyfillProperty(object, property,value); |
Stability: 4 - Stable. This function creates a writable, configurable and enumerable property with the given value in the object if the property doesn't exist in the object. The return value boolean and checks that the creating of the property was successful. |
curry(function); |
Stability: 4 - Stable. Curries a function, allowing it to be called with a single argument at a time and returning a new function that takes the next argument. The function parameter is mandatory. |
delay(ms).then(callback); |
Stability: 4 - Stable. A promise based delay function. The ms parameter is mandatory and have to be an integer (milliseconds). Sample:
CEL.delay(5000)
.then(() => alert("5 seconds"))
.catch(console.log.bind(console))
.finally(() => alert("done"));
|
deleteOwnProperty(object, property[,Throw = false]); |
Stability: 4 - Stable. This function deletes an own property in the given object. If Throw is true and the deleting was unsuccessful, then an error will be thrown. Return values: 1 - The property was own and the delete was successful. 0 - The property is own and the delete was unsuccessful. -1 - The property is not own or not exists. |
extend([deep,]target,source1[,sourceN]); |
Stability: 4 - Stable. This is an enhanced version of the Object.assign method. The deep parameter (boolean) is optional and sets the deep copy (recursive) of the sources. |
eq(value1, value2); |
Stability: 4 - Stable. SameValueZero equality (like Object.is();, but +0 === -0). All of the parameters are mandatory and can be any type. The return value is boolean. |
F(); |
Stability: 4 - Stable. This function returns false. |
getUrlVars([str=location.search]); |
Stability: 4 - Stable. Get the values of the url variables in an object from the location.search (default value) or another given url. The str parameter name is optional and can be a string.
Example: "?showall=true&order_by=updated&o=asc" -> Object { showall: "true", order_by: "updated", o: "asc" } |
gt(value1, value2); |
Stability: 4 - Stable. Strict type greater than. All of the parameters are mandatory and can be number, bigint, string or boolean, but the values have to be same type. If the type of the values are not the same, then return value is false. The return value is boolean. |
gte(value1, value2); |
Stability: 4 - Stable. Strict type greater than or equal (SameValueZero). All of the parameters are mandatory and can be number, bigint, string or boolean, but the values have to be same type. If the type of the values are not the same, then return value is false. The return value is boolean. |
identity(value); |
Stability: 4 - Stable. Return the given value. (In math: f(x)=x) |
lt(value1, value2); |
Stability: 4 - Stable. Strict type less than. All of the parameters are mandatory and can be number, bigint, string or boolean, but the values have to be same type. If the type of the values are not the same, then return value is false. The return value is boolean. |
lte(value1, value2); |
Stability: 4 - Stable. Strict type less than or equal (SameValueZero). All of the parameters are mandatory and can be number, bigint, string or boolean, but the values have to be same type. If the type of the values are not the same, then return value is false. The return value is boolean. |
nanoid([size=21[, alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-"]]); |
Stability: 4 - Stable. Generate a nanoid. The size parameter is optional and the default value is 21. The alphabet parameter is optional and the default value is "A-Za-z0-9_-". The return value is the generated nanoid (string). Example ID: "QsZA2VVTgFIF3D-qFk5oc" |
noop(); |
Stability: 4 - Stable. It's an empty function (no operation) that returns undefined and usable for optional callback arguments. |
obj2string(object); |
Stability: 4 - Stable. Convert object to a querystring. The return value is the string. The object parameter is mandatory. |
omit(object, keys); |
Stability: 4 - Stable. Exclude (filter) keys from an object and return these keys and values in a new object (immutably). All of the parameters are mandatory and the keys has to be an array. |
once(function); |
Stability: 4 - Stable. Ensures a function is only called once. The return value is a new function. The function parameter is mandatory. |
pick(object, keys); |
Stability: 4 - Stable. Select (filter) keys from an object and return these keys and values in a new object (immutably). All of the parameters are mandatory and the keys has to be an array. |
pipe(function1 [, functionN]); |
Stability: 4 - Stable. Compose functions left to right. At least one function parameter is mandatory. |
randomBoolean(); |
Stability: 4 - Stable. Get a random boolean value. The return value is true or false. |
randomUUIDv7(v4 = false); |
Stability: 4 - Stable. This function returns a UUID v7, which cointains a timestamp too. For more information please read the this page! Example result: "0195d74b-b8c8-7302-a7d3-919df45087f3"If the v4 parameter (optional) is true, then the version in the string will be 4.Example result: "0195d74b-b8c8-4302-a7d3-919df45087f3". |
sizeIn(object); |
Stability: 4 - Stable. Returns the count of the owned properties and symbols of the given object. The object parameter is mandatory. The return value is an integer. |
T(); |
Stability: 4 - Stable. This function returns true. |
tap(function): function(value); |
Stability: 4 - Stable. This functions returns a new function, which runs the given function with the value parameter, then returns the value. Usable for testing and logging. All of the parameters are mandatory. |
timestampID([size=21[,alphabet="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"]]); |
Stability: 4 - Stable. Generate a timestamp based sortable ID. The size parameter is optional and the default value is 21, but if the given value smaller than 12, then the value will be 12. The alphabet parameter is optional and the default value is "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", same as BASE58. The return value is the generated id (string).Example ID: "00lirtqi4e-wgGn8vGPyY" |
unBind(function); |
Stability: 4 - Stable. Old name before v5.4.1: toFunction.Returns an unbinded function from an object method. The function parameter is mandatory. |
String API
| Name | Description |
b64Decode(string); |
Stability: 4 - Stable. Unicode compatible base64 to string converter. Return the original string. |
b64Encode(string); |
Stability: 4 - Stable. Unicode compatible string to base64 converter. Return the encoded string. |
strAt(string,index[,newChar]); |
Stability: 4 - Stable. If the newchar is undefined, then returns the unicode character, which has to be on the given index in the string. The index can be negative value ( If the newChar is not undefined, then the indexed character will be replaced with the newChar and returns the modified string. |
strCapitalize(string); |
Stability: 4 - Stable. This function is unicode compatible and converts the first character to uppercase and the other characters to lowercase. The string parameter is mandatory. The return value is a string. |
strCodePoints(string); |
Stability: 4 - Stable. Returns the array of the unicode codepoints of characters of the given string. The string parameter is mandatory. |
strDownFirst(string); |
This function is unicode compatible and converts the first character to lowercase. The string parameter is mandatory. The return value is a string. |
strFromCodePoints(iterator); |
Stability: 4 - Stable. Returns the joined string of the given unicode codepoints. The iterator parameter is mandatory. |
strHTMLEscape(string); |
Stability: 4 - Stable. This function escapes these characters: <, >, &, ", '. The String parameter is mandatory. The return value is the escaped string. |
strHTMLRemoveTags(string); |
Stability: 4 - Stable. Remove HTML tags from the given string. The string parameter is mandatory. The return value is the new string. |
strUnHTMLEscape(string); |
Stability: 4 - Stable. This function unescapes these characters: <, >, &, ", '. The String parameter is mandatory. The return value is the unescaped string. |
strReverse(string); |
Stability: 4 - Stable. Returns the reversed variant of the given string. In the ES6 compatible browsers the result will be unicode compatible. The string parameter is mandatory. |
strPropercase(string); |
Stability: 4 - Stable. This function is unicode compatible and capitalizes every word of the given string. The string parameter is mandatory. The return value is a string. Example: CEL.strPropercase("arthur conan doyle");-> "Arthur Conan Doyle" |
strSplice(strin,index,count[,add]); |
Stability: 4 - Stable. This function works like the Array.prototype.splice(); and can remove characters on the index or replace with other string. The return value is the modified string. |
strTitlecase(string); |
Stability: 4 - Stable. Alias of the strPropercase(string);. |
strTruncate(string, newLength[,omission = ""]); |
Stability: 4 - Stable.
This function truncats the given string to the new length. If the new length is bigger than the original length, then the return value is the original string. The omission parameter is optional. Samples: CEL.strTruncate("Arthur Dent", 6); -> "Arthur"
CEL.strTruncate("Arthur Dent", 6, "..."); -> "Art..."
CEL.strTruncate("Arthur Dent", 20, "..."); -> "Arthur Dent"
|
strUpFirst(string); |
Stability: 4 - Stable. This function is unicode compatible and converts the first character to uppercase. The string parameter is mandatory. The return value is a string. |
Legacy Assertion API
These functions have been removed in v6.3.0, because the first stable version of the assert.js library has been published.
DOM API
| Name | Description |
createFile(filename,content[,dataType]); |
Stability: 4 - Stable. Doesn't work in iOS browsers (Safari, Firefox and Chrome) and W10M Edge 14. |
domClear(element); |
Stability: 4 - Stable. Remove all child element of the given element. The parameter is mandatory. |
domCreate(type[,properties[,innerHTML]]); |
Stability: 4 - Stable. Create a new HTML element. The type is mandatory and has to be a string. The properties object is optional and sets the element properties. (class, style object/string, data-*, etc.) The innerHTML is optional and can be a string. |
domCreate(element descriptive object); |
Stability: 4 - Stable. Since v2.0.5, a new element can be created with an object. In this case the element descriptive object is mandatory. The Sample code: CEL.domCreate({
elementType: "a",
href: "https://developer.mozilla.org/en-US/",
target: "_blank",
style: {
"background-color": "red",
"color": "white"
},
innerHTML: "MDN Sample url"
});
|
domFadeIn(element [,duration [,display]]); |
Stability: 4 - Stable. Fade in and show animation for an element. The element is mandatory and has to be a HTML element. The duration parameter is optional and sets the animation time in milisec (the default is 500ms). The display is optional and can be a string (CSS display property values). |
domFadeOut(element [,duration]); |
Stability: 4 - Stable. Fade out and hide animation for an element. The element is mandatory and has to be a HTML element. The duration parameter is optional and sets the animation time in milisec (the default is 500ms). |
domFadeToggle(element [,duration [,display]]); |
Stability: 4 - Stable. Fade in or fade out animation which depends on the state of the element. The element is mandatory and has to be a HTML element. The duration parameter is optional and sets the animation time in millisecond (the default is 500ms). The display is optional and can be a string (CSS display property values). |
domGetCSS(element [,property]); |
Stability: 4 - Stable. Get a CSS property value of an element or all of the css properties in an object. The element is mandatory and has to be a HTML element. The property is optional and can be a string. |
domGetCSSVar(name); |
Stability: 4 - Stable. This function returns a value of a CSS variable or an empty string, if the variable is unset. The name parameter is mandatory and has to be a string. If the "--" characters are missing at the begin of the variable name, then the function will add these. |
domHide(element); |
Stability: 4 - Stable. Hide an element. The element is mandatory and has to be a HTML element. |
domIsHidden(element); |
Stability: 4 - Stable. This function determines whether the element is hidden. The element is mandatory and has to be a HTML element. The return value is boolean. |
domReady(callback); |
Stability: 4 - Stable. Set the document ready (content fully loaded) event. |
domSetCSS(element, property,value); |
Stability: 4 - Stable. Set a CSS property value of an element. The element is mandatory and has to be a HTML element. The property is mandatory and has to be a string. The value is mandatory and has to be a string. |
domSetCSS(element, properties); |
Stability: 4 - Stable. Set CSS property values of an element. The element is mandatory and has to be a HTML element. The properties object is mandatory. The object properties can be the CSS properties and the property values will be applied to the element. |
domSetCSSVar(name,value); |
Stability: 4 - Stable. This function set a value of a CSS variable. Both of the parameters are mandatory and have to be a string. If the "--" characters are missing at the begin of the variable name, then the function will add these. |
domShow(element [,display]); |
Stability: 4 - Stable. Show an element. The element is mandatory and has to be a HTML element. The display is optional and can be a string (CSS display values). |
domScrollToBottom(); |
Old name before v5.5.4: domToBottom.This function is scrolling to the bottom of the page. |
domScrollToElement(element [,top=true]); |
Stability: 4 - Stable. This function is scrolling to top or the bottom of element. The element parameter is mandatory and the top parameter is optional and can be boolean. |
domScrollToTop(); |
Stability: 4 - Stable. Old name before v5.5.4: domToTop.This function is scrolling to the top of the page. |
domSiblings(element); |
Stability: 4 - Stable. Get the siblings of an element. The element parameter is mandatory and the return value is the array. |
domSiblingsLeft(element); |
Stability: 4 - Stable. Alias of the domSiblingsPrev(element);. |
domSiblingsNext(element); |
Stability: 4 - Stable. Get the next siblings of an element. The element parameter is mandatory and the return value is the array. |
domSiblingsPrev(element); |
Stability: 4 - Stable. Get the previous siblings of an element. The element parameter is mandatory and the return value is the array. |
domSiblingsRight(element); |
Stability: 4 - Stable. Alias of the domSiblingsNext(element);. |
domToElement(htmlString); |
Stability: 4 - Stable. This function returns a HTML element which is created from the htmlString parameter. The htmlString parameter is mandatory and has to be a string. |
domToggle(element [,display]); |
Stability: 4 - Stable. Show or hide an element. The element is mandatory and has to be a HTML element. The display is optional and can be a string (CSS display values). |
importScript(script1[,scriptN]); |
Stability: 4 - Stable. Load JavaScript files. The first parameter is mandatory and has to be a string. The other parameters are optional and can be a string. Tip: |
importStyle(style1[,styleN]); |
Stability: 4 - Stable. Load CSS files. The first parameter is mandatory and has to be a string. The other parameters are optional and can be a string. |
form2array(form); |
Stability: 4 - Stable. Convert (serialize) form input tag names and values to an array with object elements (name and value properties). The return value is the array. The form parameter is mandatory and has to be a html form element. |
form2string(form); |
Stability: 4 - Stable. Convert (serialize) form input tag names and values to a query string. The return value is the string. The form parameter is mandatory and has to be a html form element. |
getDoNotTrack(); |
Stability: 4 - Stable. Return the DoNotTrack setting (boolean) of the browser. |
getFullscreen(); |
Stability: 4 - Stable. Get the fullscreen element. If this isn't set, then the return value is undefined. Please check the incompatibility issues on the http://caniuse.com/#search=fullscreen page. |
getLocation(success[,error]); |
Stability: 4 - Stable. Get the current location as an object with the coordinates. The success is mandatory and has to be a function. The error is optional and can be a function. |
setFullscreenOff(); |
Stability: 4 - Stable. Set off the fullscreen. |
setFullscreenOn(selector); |
Stability: 4 - Stable. Set the fullscreen element. The selector can be a css selector string or an element. |
qs(selector[,context]); |
Stability: 4 - Stable. Get the first matched HTML element. The context is optional and can be an element. |
qsa(selector[,context]); |
Stability: 4 - Stable. Get matched HTML elements in an array. The context is optional and can be an element. |
Legacy AJAX API
These functions have been removed in v6.3.0. It's recommend to use the Fetch API, because this is supported in every modern browsers.
Type API
| Name | Description |
is(value[,expectedType[,Throw=false]]; |
Stability: 4 - Stable. This function determines whether the provided value type or class is the given expectedType. The expectedType can be a type string, constructor function or an array of the type strings and constructors. If the Throw is true and the value is not matched with the expectedType, then a TypeError will be thrown with detailed error message. The return value is boolean or the type or constructor of the value. |
isTypedCollection(iter, expectedType, Throw = false); |
Stability: 4 - Stable. This function determines whether values of the provided iterable or iterator are the given expectedType. The expectedType is mandatory and can be a type string, constructor function or an array of the type strings and constructors. If the Throw is true and the values are not matched with the expectedType, then a TypeError will be thrown with detailed error message. The return value is boolean. |
isArraylike(value); |
Stability: 4 - Stable. This function determines whether the provided value is an arraylike object. The return value is boolean. |
isAsyncIterable(value); |
Stability: 4 - Stable. This function determines whether the provided value is an async iterable object. The return value is boolean. |
isAsyncFn(value); |
Stability: 4 - Stable. This function determines whether the provided value is an async function. The return value is boolean. |
isAsyncGeneratorFn(value); |
Stability: 4 - Stable. This function determines whether the provided value is an async generator function. The return value is boolean. |
isCallable(value); |
Stability: 4 - Stable. This function determines whether the provided object has a call method. The return value is boolean. |
isChar(value); |
Stability: 4 - Stable. This function determines whether the provided value is a string with length 1 character. This function is unicode compatible. The return value is boolean. |
isCoercedObject(object); |
Stability: 4 - Stable. If the given object is a coerced object (Number, BigInt, String, Boolean), then the return value is the constructor function. In any other cases retuns false. The object parameter is mandatory. |
isDeepStrictEqual(value1, value2); |
Stability: 4 - Stable. This function determines whether the provided values are deep equals. (Deep strict equality + NaN equality: primitives (SameValue - Object.is()), Array, TypedArray, Plain Object, Map, Set, WeakMap (only reference), WeakSet (only reference), Object wrappers (primitives), Function (only reference), RegExp, Error, Date, DataView, ArrayBuffer) The return value is boolean. |
isElement(value); |
Stability: 4 - Stable. This function determines whether the provided value is a HTML element. The return value is boolean.
For other node types (document, text, comment, etc.) checking please read this MDN page:
|
isEmptyValue(value); |
Stability: 4 - Stable. This function determines whether the provided value is an empty value. Returns true in these cases: null, undefined, NaN, array, typedarray, arraybuffer, dataview, object, arraylike object, map, set, iterator, iterable. The return value is boolean. |
isFunction(value); |
Stability: 4 - Stable. This function determines whether the provided value is a function. The return value is boolean. |
isGeneratorFn(value); |
Stability: 4 - Stable. This function determines whether the provided value is a generator function. The return value is boolean. |
isIndex(value); |
Stability: 4 - Stable. This function determines whether the provided value is a valid arraylike index number. The return value is boolean. |
isIterable(value); |
Stability: 4 - Stable. This function determines whether the provided value is an iterable object. The return value is boolean. |
isIterator(value); |
Stability: 4 - Stable. This function determines whether the provided value is an iterator. The return value is boolean. |
isLength(value); |
Stability: 4 - Stable. Alias of isIndex(value);. |
isNonNullable(value); |
Stability: 4 - Stable. Checks if the given value is NonNullable (not null or undefined). The value parameter is mandatory and can be any type. The return value is boolean. |
isNonNullablePrimitive(value); |
Stability: 4 - Stable. Checks if the given value is NonNullable (not null, undefined, object or function). The value parameter is mandatory and can be any type. The return value is boolean. |
isNull(value); |
Stability: 4 - Stable. This function determines whether the provided value is null. The return value is boolean. |
isNullish(value); |
Stability: 4 - Stable. Old name before v6.1.0: isNil();.This function determines whether the provided value is null or undefined. The return value is boolean. |
isNumeric(value); |
Stability: 4 - Stable. This function determines whether the provided value is a number or can be converted to number. The return value is boolean. |
isObject(value); |
Stability: 4 - Stable. This function determines whether the provided value is an object or function and not null. The return value is boolean. |
isPlainObject(value); |
Stability: 4 - Stable. This function determines whether the provided value is an object, which own prototype is the Object.prototype or null. The return value is boolean. |
isPrimitive(value); |
Stability: 4 - Stable. This function determines whether the provided value is not null, not object and not function. The return value is boolean. |
isPropertyKey(value); |
Stability: 4 - Stable. This function determines whether the provided value is a valid propertx key (string or symbol). The return value is boolean. |
isProxy(value); |
Stability: 4 - Stable. This function determines whether the provided value is a proxy. The return value is boolean. |
isRegexp(value); |
Stability: 4 - Stable. This function determines whether the provided value is a regexp. The return value is boolean. |
isSameInstance(value1, value2,Contructor); |
Stability: 4 - Stable. This function returns true if the values are same class and uses the instanceof operator. The parameters are mandatory. The return value is boolean. |
isSameType(value1, value2); |
Stability: 4 - Stable. This function returns true if the values are same type or both are null or both are undefined. The parameters are mandatory. The return value is boolean. |
isTypedArray(value); |
Stability: 4 - Stable. This function determines whether the provided value is a typedarray. The return value is boolean. |
isUndefined(value); |
Stability: 4 - Stable. This function determines whether the provided value is undefined. The return value is boolean. |
toIndex(value); |
Stability: 4 - Stable. This function converts the provided value to a valid arraylike index number. The return value is an unsigned integer (number). If the value is out of integer range, then a RangeError will be thrown. |
toLength(value); |
Stability: 4 - Stable. This function converts the provided value to a valid arraylike length number. The return value is an unsigned integer (number). |
toObject(value); |
Stability: 4 - Stable. If the given value is not null or undefined, then the return value is an object, which has been converted from the value, else a TypeError() will be throwned.If the given value is an object, function or symbol, then the original value will return. |
toPrimitiveValue(value); |
Stability: 4 - Stable. If the given value is null or undefined, then a TypeError() will be throwned.If the given value is an object, which can be converted to a primitive variable, then the return value is a primitive variable. If the given value is a not convertable object (array, map, set, etc.), function or symbol, then the original value will return. |
toPropertyKey(value); |
Stability: 4 - Stable. This function convert the given value to a valid property key. If the value is not symbol, then will be converted to string, else the symbol will be returned. |
toSafeString(value); |
Stability: 4 - Stable. This function is a general purpose, type safe, predictable stringifier. The value parameter is mandatory and can be any type. The return value is a string. |
typeOf(value); |
Stability: 4 - Stable. Old name before v6.1.0: type();.This function returns the typeof operator result of the given value, except the null object ( "null" instead of "object"). |
Cookie API
Cookie values help: MDN, web.dev
| Name | Description |
clearCookies([path="/"[, domain[, secure[, SameSite="Lax"[, HttpOnly]]]]]); |
Stability: 4 - Stable. Clear all of the cookies. The return value (boolean) is determines whether the cookie was set with the name before the removing. Function parameters:
|
clearCookies(Options object); |
Stability: 4 - Stable. In this case the names of object properties are the same as the function arguments and the default values are the same too. |
getCookie([name]); |
Stability: 4 - Stable. Get the value of a cookie or all cookies in an object. With the name parameter (string) the return value is the current cookie value or null. Without the parameter the return value is an object with the values or an empty object. |
hasCookie(name); |
Stability: 4 - Stable. This function determines whether the cookie is set with the name parameter. The return value is boolean. |
removeCookie(name[, path="/"[, domain[, secure[, SameSite="Lax"[, HttpOnly]]]]]); |
Stability: 4 - Stable. Remove a cookie. The return value (boolean) is determines whether the cookie was set with the name before the removing. Function parameters:
The return value (boolean) is determines whether the cookie was set with the name before the removing. |
removeCookie(Options object); |
Stability: 4 - Stable. In this case the names of object properties are the same as the function arguments and the default values are the same too. |
setCookie(name, value[, hours="8760"[, path="/"[, domain[, secure[, SameSite="Lax"[, HttpOnly]]]]]]); |
Stability: 4 - Stable. Set a cookie. Function parameters:
|
setCookie(Options object); |
Stability: 4 - Stable. In this case the names of object properties are the same as the function arguments and the default values are the same too. |
Collections API
| Name | Description | |
arrayAdd(array,value); |
Stability: 4 - Stable. Push the value to the array if the array doesn't contain the value. The return value is true, when the value is added and false, when not added. |
|
arrayClear(array); |
Stability: 4 - Stable. Clear the array and returns the empty array. The array parameter is mandatory. |
|
arrayCycle(iterator[,n=100]); |
Stability: 4 - Stable. Cycle the given iterator and returns an array with these elements. The iterator parameter is mandatory. The n parameter is optional and can be an integer. Default parameter value: n = 100. |
|
arrayDeepClone(array); |
Stability: 4 - Stable. This function deeply (recursively) clones an array. The return value is the cloned array. |
|
arrayMerge(target,source1[,sourceN]); |
Stability: 4 - Stable. Merge two or more arrays or push any values in the target array. The return value is the target array. |
|
arrayRange([start=0[,end=99[,step=1]]]); |
Stability: 4 - Stable. Returns the array of values between the start and end parameters. All of the parameters are mandatory and have to be a number. Default parameter values: start = 0, end = 99, step = 1. Example: CEL.arrayRange("A".codePointAt(0),"Z".codePointAt(0)).map((v)=>String.fromCodePoint(v));-> code>Array(26) [ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ]
|
|
arrayRemove(array,value[,all=false]); |
Stability: 4 - Stable. Remove the first or all equivalent values from the array. Returns true, when the value was found and false when not found. The array and value parameters are mandatory. The all parameter is optional and has to be a boolean. |
|
arrayRemoveBy(array,callback[,all=false]); |
Stability: 4 - Stable. Remove the first or all values from the array with which the given function returns true. Returns true, when the value was found and false when not found. The array and callback parameters are mandatory. The all parameter is optional and has to be a boolean. |
|
arrayRepeat(value[,step=100]); |
Stability: 4 - Stable. Returns an array with same repeatedly elements. The value parameter is mandatory and the n parameter is optional and can be an integer. Default parameter value: n = 100. |
|
castArray([value]); |
Stability: 4 - Stable. This function returns the original value if this is an array or value a new array. If there is no given value, then the return value is an empty array. |
|
concat(iterator1[,iteratorN]); |
Stability: 4 - Stable. This function merges the iterators and yields the elements of the merged iterator. The given iterators will be not changed. At least one iterator has to been given. |
|
compact(iterator); |
Stability: 4 - Stable. This Returns an array with truthy values (but keeps 0) from the given Iterable or ArrayLike object. The iterator parameter is mandatory. |
|
count((iterator,callback);); |
Stability: 4 - Stable. This function executes a counter function (that you provide) on each element of the iterator, returning in a single output value. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function. |
|
drop(iterator[,n=1]); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).drop();Drop the first N elements of an iterator and yield the remained elements. The iterator parameter is mandatory. The n parameter is optional and can be an integer. Default parameter value: n = 1 |
|
dropRight(iterator[,n=1]); |
Stability: 4 - Stable. Drop the last N elements of an iterator and return the remained elements in an array. The iterator parameter is mandatory. The n parameter is optional and can be an integer. Default parameter value: n = 1. |
|
dropRightWhile(iterator,callback); |
Stability: 4 - Stable. Drop the elements from the end of an iterator while the callback (filter) function returns true and yield the remained elements. The callback function will be called with the actual element of the iterator. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function. |
|
dropWhile(iterator,callback); |
Stability: 4 - Stable. Drop the elements of an iterator while the callback (filter) function returns true and yield the remained elements. The callback function will be called with the actual element of the iterator. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function. |
|
enumerate(iterator[,offset=0]); |
Stability: 4 - Stable. Yield generated pairs (arrays) from the elements of a iterator and a counter. The iterator parameter is mandatory. The offset parameter is optional and can be an integer and it's default value is 0. Example: |
|
every(iterator,callback); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).every();This function whether all elements in the iterator pass the test implemented by the provided function. It returns a Boolean value and all of the parameters are mandatory. If the iterator is empty, then the return value is false. |
|
filter(iterator,callback); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).filter();Filter and yield elements of an iterator. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function and called with two parameters: the item and the index of the item (only a counter). |
|
find(iterator,callback); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).find();This function returns the value of the first element in the iterator that satisfies the provided testing function. Otherwise undefined is returned. All of the parameters are mandatory. |
|
findLast(iterator,callback); |
Stability: 4 - Stable. This function returns the value of the last element in the iterator that satisfies the provided testing function. Otherwise undefined is returned. All of the parameters are mandatory. |
|
first(iterator); |
Stability: 4 - Stable. This function returns the first element of the given iterator. The iterator parameter is mandatory. |
|
forEach(iterator,callback); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).forEach();This function executes a provided function once for each iterator items. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function and called with two parameters: the item and the index of the item (only a counter). |
|
forEachRight(iterator,callback); |
Stability: 4 - Stable. This function executes a provided function once for each iterator items in reversed order. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function and called with two parameters: the item and the index of the item (only a reversed counter). |
|
head(iterator); |
Stability: 4 - Stable. This is an alias of the first(iterator);. |
|
includes(iterator,value); |
Stability: 4 - Stable. This function determines whether a collection includes a certain value among its entries, returning true or false as appropriate. The collection and the value of the parameters are mandatory and the comparator is optional. The default comparasion is SameValueZero algorithm, but with the comparator (function) can be other solution. (e.g.: Object.is, which uses the SameValue algorithm). The collection can be: String (uses the String#includes method), String object (uses the String#includes method), Map, Iterables (Array, Set, TypedArrays, other Iterables), plain objects, functions (as object). The own keys, values, symbols are compared, example: CEL.includes({"lorem": "ipsum","1": 0}, -0); returns true. |
|
initial(iterator); |
Stability: 4 - Stable. Returns an array with the values of the given iterator, but without the last value.
Example:
|
|
isSuperset(superCollection,subCollection); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Set.prototype.isSupersetOf();.This function determines whether the first provided iterator is superset of the second iterator. The parameters are mandatory and all parameters can be an iterator. The return value is a boolean. |
|
item(iterator,index); |
Stability: 4 - Stable. This function returns the item from the given iterator on the given index. The iterator parameter is mandatory and has to be an iterator/iterable. The index is mandatory and can be a positive integer (examples: 0 = the first item, 1 = the second item, 2 = the third item, etc.) Compatible with the Unicode strings. |
|
iterCycle(iter[,n=Infinity]); |
Stability: 4 - Stable. Yield the items of an iterator over and over. The iter parameter is mandatory and the n parameter is optional and can be an integer. Default parameter value: n = Infinity
|
|
iterRange([start=0[,step=1[,end=Infinity]]]); |
Stability: 4 - Stable. Yield a range (counter) iterator. All of the parameters are optional. Default parameter values: start = 0, step = 1, end = Infinity. |
|
iterRepeat(value[,n=Infinity]); |
Stability: 4 - Stable. Yield a value over and over. The value parameter is mandatory and the n parameter is optional and can be an integer. Default parameter value: n = Infinity |
|
join(iterator[,separator=","]); |
Stability: 4 - Stable. This function creates and returns a new string by concatenating all of the elements in an iterator, separated by commas or a specified separator string. The separator is converted to a string if necessary. If the iterator has only one item, then that item will be returned without using the separator. The iterator parameter is mandatory. |
|
flat(iterator); |
Stability: 4 - Stable. Yield the subelements of the elements of the given iterator. the iterator parameter is mandatory and all of the elements have to be an iterator or iterable. |
|
last(iterator); |
Stability: 4 - Stable. This function returns the last element of the given iterator. The iterator parameter is mandatory. |
|
map(iterator,callback); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).map();This function creates a new iterator with the results of calling a provided function on every element. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function and called with two parameters: the item and the index of the item (only a counter). |
|
max(value1[,valueN]); |
Stability: 4 - Stable. Returns the maximum value of the given values. The first value parameter is mandatory and can be any type. Works with any type of values, not only with numbers. |
|
min(value1[,valueN]); |
Stability: 4 - Stable. Returns the minimum value of the given values. The first value parameter is mandatory and can be any type. Works with any type of values, not only with numbers. |
|
none(iterator,callback); |
Stability: 4 - Stable. This function whether all elements in the iterator do not pass the test implemented by the provided function. It returns a Boolean value and all of the parameters are mandatory. If the iterator is empty, then the return value is false. |
|
nth(iterator,index); |
Stability: 4 - Stable. This is an alias of the item(iterator,index);. | |
partition(iterator,callback); |
Stability: 4 - Stable. Returns an array, with filtered and negative filtered groups of the elements of the original iterator. All of the parameters are mandatory.
Example:
|
|
reduce(iterator,callback[,initialvalue]); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).reduce();This function executes a reducer function (that you provide) on each element of the iterator, returning in a single output value. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function. The initialvalue parameter is optional and can be any variable type of the Javascript. |
|
reject(iterator,callback); |
Stability: 4 - Stable. This is the opposite of the function filter(iterator,callback);. The elements to which the given callback gives a false will be yield. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function and called with two parameters: the item and the index of the item (only a counter). |
|
reverse(iterator); |
Stability: 4 - Stable. This function returns an iterator with values of the given iterator in reverse order. The iterator parameter is mandatory. |
|
setDifference(set1,set2); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Set.prototype.difference();.Returns the set of unique values that are in the iterator1, excluding the values that are also in the iterator2. All of the parameters are mandatory and have to be a Set. The return value is a Set. |
|
setIntersection(set1,set2); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Set.prototype.intersection();.Returns the set of unique values that are in both of the given iterators. All of the parameters are mandatory and have to be a Set. The return value is a Set. |
|
setSymmetricDifference(set1,set2); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Set.prototype.symmetricDifference();.Returns the set of unique values that are only in one of given iterators. All of the parameters are mandatory and have to be a Set. The return value is a Set. |
|
setUnion(iterator1[,iteratorN]); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Set.prototype.union();.Returns the set of unique values including all values from the given iterators. The first parameter is mandatory. The return value is a Set. |
|
size(iterator); |
Stability: 4 - Stable. This function returns the count of the elements in the given iterator. The iterator parameter is mandatory. The return value is an integer. |
|
shuffle(iterator); |
Stability: 4 - Stable. Returns an array with the values of the given iterator, but in shuffled order.
Example:
|
|
slice(iterator[,begin=0[,end=Infinity]]); |
Stability: 4 - Stable. Take a slice of an iterator and yield the elements. The iterator parameter is mandatory. The begin parameter is optional and can be a number and the default value is 0. The end parameter is optional and can be a number and the default value is Infinity. |
|
some(iterator,callback); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).some();This function tests whether at least one element in the array passes the test implemented by the provided function. It returns a Boolean value and all of the parameters are mandatory. If the iterator is empty, then the return value is false. |
|
sort(iterator[,numbers=false]); |
Stability: 4 - Stable. This function sorts the values of the given iterator. The iterator parameter is mandatory. The numbers paramater is optional (boolean) and set true, if the iterator contains only numbers. The return value is an array. |
|
tail(iterator); |
Stability: 4 - Stable. Yield the values of an iterator but without the first value. The iterator parameter is mandatory. |
|
take(iterator[,n=1]); |
Stability: 3 - Legacy and can get only fixes. Can be replaced with Iterator.from(iterable/iterator).take();Yield the first N elements of an iterator. The iterator parameter is mandatory. The n parameter is optional and can be an integer. Default parameter value: n = 1 |
|
takeRight(iterator[,n=1]); |
Stability: 4 - Stable. Take the last N elements of an iterator. The iterator parameter is mandatory. The n parameter is optional and can be an integer. Default parameter value: n = 1. The return value is an array. |
|
takeRightWhile(iterator,callback); |
Stability: 4 - Stable. Yield the elements from the end of an iterator while the callback (filter) function returns true. The callback function will be called with the actual element of the iterator. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function. |
|
takeWhile(iterator,callback); |
Stability: 4 - Stable. Yield the elements of an iterator while the callback (filter) function returns true. The callback function will be called with the actual element of the iterator. The iterator parameter is mandatory. The callback parameter is mandatory and has to be a function. |
|
unique(iterator[, resolver]); |
Stability: 4 - Stable. This function returns a new iterator with unique values. The iterator parameter is mandatory. The resolver parameter can be an object field name or function. Examples Without resolver:
JSON.stringify( CEL.unique( [1, 2, 2, 3] ) );
// '[1,2,3]'
With resolver:
let array = [
{ "name": "Picard", "rank": "captain" },
{ "name": "Riker", "rank": "captain" },
{ "name": "Data", "rank": "commander" },
{ "name": "Troi", "rank": "commander" }
];
// key resolver
JSON.stringify( CEL.unique(array, "rank") );
// '[{"name":"Picard","rank":"captain"},{"name":"Data","rank":"commander"}]'
// function resolver
JSON.stringify( CEL.unique(array, (v) => v.rank) );
// '[{"name":"Picard","rank":"captain"},{"name":"Data","rank":"commander"}]'
|
|
unzip(iterator); |
Stability: 4 - Stable. Returns the array of arrays of unpaired values. In the modern browsers compatible with finite iterators. Example: CEL.unzip([ [ "a", 3 ], [ "b", 4 ], [ "c", 5 ], [ "d", 6 ] ]);-> Array (2) [ ["a","b","c","d"], [3,4,5,6] ] |
|
withOut(iterator,filterIterator); |
Stability: 4 - Stable. Returns an array with the values of the first iterator, but without the values of the filterIterator. All of the parameters are mandatory.
Example:
|
|
zip(iterator1[,iteratorN]); |
Stability: 4 - Stable. Returns the array of paired values of the given iterators. In the modern browsers compatible with finite iterators. Example: CEL.zip(["a","b","c","d"], [3,4,5,6,7,8,9]);-> Array (4) [ [ "a", 3 ], [ "b", 4 ], [ "c", 5 ], [ "d", 6 ] ] |
|
zipObj(iterator1, iterator2); |
Stability: 4 - Stable. Returns an object, whose properties are from the first iterator and its values are from the second iterator. The two iterators must be the same size. In the modern browsers compatible with finite iterators. Example: zipObj(["a","b","c"],[1,2,3])-> {"a":1,"b":2,"c":3} |
Abstract API
The Ecmascript abstract functions are available in the Zephyr library.
Math API
| Name | Description |
add(value1,value2); |
Stability: 4 - Stable. Performs addition type safely. Works for both number and bigint values. All of the parameter is mandatory and can be both number or both bigint. The return value is number or bigint. |
avg(value1[,valueN]); |
Stability: 4 - Stable. This function returns the average value from the parameter values. |
clamp(value,min,max); |
Stability: 4 - Stable. If the given value is between the min and max values, then this function returns the value. If smaller then the min value, then the return value is the min. If greater then the max value, then the return value is the max. All of the parameters are mandatory and can be number or bigint and if not these types, then will be converted to number. The return value is number or bigint or throw a rangeerror, if the parameters are invalid. |
div(value1,value2); |
Stability: 4 - Stable. Performs integer division type safely. Works for both number and bigint values. All of the parameter is mandatory and can be both number or both bigint. The return value is number or bigint. |
divMod(value1,value2); |
Stability: 4 - Stable. Performs integer division type safely. Works for both number and bigint values. All of the parameter is mandatory and can be both number or both bigint. The return value is number or bigint. |
inRange(value,min,max); |
Stability: 4 - Stable. This function determines whether the provided value is between the min and max values. All of the parameters are mandatory and have to be number. The return value is boolean. |
isEven(value); |
Stability: 4 - Stable. This function determines whether the provided value is an even number. The return value is boolean. |
isBigInt64(value); |
Stability: 4 - Stable. This function determines whether the provided value is a BigInt (Int64) value between -2^63 and 2^63 - 1. The return value is boolean. |
isBigUInt64(value); |
Stability: 4 - Stable. This function determines whether the provided value is a BigInt (Int64) value between 0 and 2^64 - 1. The return value is boolean. |
isFloat(value); |
Stability: 4 - Stable. This function determines whether the provided value is a float number. The return value is boolean. |
isInt8(value); |
Stability: 4 - Stable. This function determines whether the provided value is an integer between -128 and 127. The return value is boolean. |
isUInt16(value); |
Stability: 4 - Stable. This function determines whether the provided value is an integer between 0 and 65535. The return value is boolean. |
isInt32(value); |
Stability: 4 - Stable. This function determines whether the provided value is an integer between -2147483648 and 2147483647. The return value is boolean. |
isOdd(value); |
Stability: 4 - Stable. This function determines whether the provided value is an odd number. The return value is boolean. |
isUInt8(value); |
Stability: 4 - Stable. This function determines whether the provided value is an integer between 0 and 255. The return value is boolean. |
isInt16(value); |
Stability: 4 - Stable. This function determines whether the provided value is an integer between -32768 and 32767. The return value is boolean. |
isUInt32(value); |
Stability: 4 - Stable. This function determines whether the provided value is an integer between 0 and 4294967295. The return value is boolean. |
isFloat16(value); |
Stability: 4 - Stable. This function determines whether the provided value is a number between -65504 and 65504. The return value is boolean. |
minmax(value,min,max); |
Stability: 4 - Stable. This is an alias of the clamp(value,min,max);. |
mod(value1,value2); |
Stability: 4 - Stable. Computes the integer remainder (modulus) type safely. Works for both number and bigint values. All of the parameter is mandatory and can be both number or both bigint. The return value is number or bigint. |
mul(value1,value2); |
Stability: 4 - Stable. Performs multiplication type safely. Works for both number and bigint values. All of the parameter is mandatory and can be both number or both bigint. The return value is number or bigint. |
product(value1[,valueN]); |
Stability: 4 - Stable. This function returns the product value from the parameter values. |
randomFloat([max]); |
Stability: 4 - Stable. Get a random float number value within 0 and max value. Without parameter the maximum value is 100. |
randomFloat(min,max); |
Stability: 4 - Stable. Get a random float number value within min and max value. |
randomInt([max]); |
Stability: 4 - Stable. Get a random integer number value within 0 and max value. Without parameter the maximum value is 100. |
randomInt(min,max); |
Stability: 4 - Stable. Get a random integer number value within min and max value. |
signbit(value); |
Stability: 4 - Stable. This function is based on this proposal:
Returns whether the sign bit of x is set. If n is NaN, the result is false. If n is -0, the result is true. If n is negative, the result is true. Otherwise, the result is false. The value parameter is mandatory. |
sum(value1[,valueN]); |
Stability: 4 - Stable. This function returns the sum value from the parameter values. |
sub(value1,value2); |
Stability: 4 - Stable. Performs subtraction type safely. Works for both number and bigint values. All of the parameter is mandatory and can be both number or both bigint. The return value is number or bigint. |
toBigInt64(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to BigInt (Int64) value (-2^63 to 2^63 - 1). |
toBigUInt64(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to unsigned BigInt (Int64) value (0 to 2^64 - 1). |
toFloat16(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to float 16 value (-65504 to 65504). |
toFloat32(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to float 32 value (-3.4e38 to 3.4e38). |
toInt8(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to integer 8 value (-127 to 128). |
toInt32(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to integer 32 value (-2147483648 to 2147483647). |
toInteger(value); |
Stability: 4 - Stable. This function always converts the provided value to an integer. If the value cannot be converted to an integer, then the return value is 0. |
toIntegerOrInfinity(value); |
Stability: 4 - Stable. This function always converts the provided value to an integer or Infitiy or -Infinity. If the value cannot be converted to an integer, then the return value is 0. |
toUInt8(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to unsigned integer 8 value (0 to 255). |
toUInt16(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to unsigned integer 16 value (0 to 65535). |
toUInt32(value); |
Stability: 4 - Stable. This function clamps ("minmax") the given value to unsigned integer 32 value (0 to 4294967295). |
Polyfills
| Name | Description |
Array.fromAsync(); |
The Array.fromAsync() static method creates a new, shallow-copied Array instance from an async iterable, iterable, or array-like object. For more information please read the MDN Article! |
Array.prototype.toReversed(); |
The toReversed() method of an Array instance is the copying counterpart of the reverse() method. It returns a new array with the elements in reversed order. For more information please read the MDN Article! |
Array.prototype.toSorted(); |
The toSorted() method of an Array instance is the copying version of the sort() method. It returns a new array with the elements sorted in ascending order. For more information please read the MDN Article! |
Array.prototype.toSpliced(); |
The toSpliced() method of an Array instance is the copying version of the splice() method. It returns a new array with some elements removed and/or replaced at a given index. For more information please read the MDN Article! |
Array.prototype.with(); |
The with() method of an Array instance is the copying version of using the bracket notation to change the value of a given index. It returns a new array with the element at the given index replaced with the given value. For more information please read the MDN Article! |
crypto.randomUUID(); |
The randomUUID() method of the Crypto interface is used to generate a v4 UUID using a cryptographically secure random number generator. For more information please read the MDN Article! |
Error.isError(); |
The Error.isError() static method determines whether the passed value is an Error or DOMException. For more information please read the MDN Article! |
globalThis; |
The "global" property of the global object, a writable, configurable, non-enumerable alias of window/self. For more information please read the MDN Article! |
Map.groupBy(); |
The Map.groupBy() static method groups the elements of a given iterable using the values returned by a provided callback function. The final returned Map uses the unique values from the test function as keys, which can be used to get the array of elements in each group. For more information please read the MDN Article! |
Math.sumPrecise(); |
The Math.sumPrecise() static method takes an iterable of numbers and returns the sum of them. It is more precise than summing them up in a loop, because it avoids floating point precision loss in intermediate results. For more information please read the MDN Article! |
Object.groupBy(); |
The Object.groupBy() static method groups the elements of a given iterable according to the string values returned by a provided callback function. The returned object has separate properties for each group, containing arrays with the elements in the group. For more information please read the MDN Article! |
Object.hasOwn(); |
The Object.hasOwn() static method returns true if the specified object has the indicated property as its own property. If the property is inherited, or does not exist, the method returns false. For more information please read the MDN Article! |
TypedArray.prototype.toReversed(); |
The toReversed() method is the copying counterpart of the reverse() method. It returns a new array with the elements in reversed order. This method has the same algorithm as Array.prototype.reverse(). For more information please read the MDN Article! |
TypedArray.prototype.toSorted(); |
The toSorted() method is the copying version of the sort() method. It returns a new array with the elements sorted in ascending order. This method has the same algorithm as Array.prototype.toSorted(), except that it sorts the values numerically instead of as strings by default. For more information please read the MDN Article! |
TypedArray.prototype.with(); |
The with() method is the copying version of using the bracket notation to change the value of a given index. It returns a new array with the element at the given index replaced with the given value. This method has the same algorithm as Array.prototype.with(). For more information please read the MDN Article! |
globalThis.AsyncFunction(); |
The AsyncFunction constructor creates a new async function object. In JavaScript, every asynchronous function is actually an AsyncFunction object. Note that AsyncFunction is not a global object, but in the Celestra this is available in the globalThis object. For more information please read the MDN Article! |
globalthis.AsyncGeneratorFunction(); |
The AsyncGeneratorFunction() constructor creates AsyncGeneratorFunction objects. Note that AsyncGeneratorFunction is not a global object, but in the Celestra this is available in the globalThis object. For more information please read the MDN Article! |
globalThis.GeneratorFunction(); |
The GeneratorFunction constructor creates a new generator function object. In JavaScript every generator function is actually a GeneratorFunction object. Note that GeneratorFunction is not a global object, but in the Celestra this is available in the globalThis object. For more information please read the MDN Article! |
| REMOVED polyfills in v3.1.0 | Array.from();Array.of();Array.prototype.fill();Array.prototype.find();Array.prototype.findIndex();Object.create();String.prototype.startsWith();String.prototype.endsWith();Array.prototype.copyWithin();String.fromCodePoint();String.prototype.codePointAt();Number.EPSILON;Number.isNaN();isNaN();Number.isInteger();Number.isFinite();Number.isSafeInteger();Number.parseInt();Number.parseFloat();Math.acosh();Math.asinh();Math.atanh();Math.cbrt();Math.clz32();Math.cosh();Math.expm1();Math.fround();Math.hypot();Math.imul();Math.log1p();Math.log10();Math.log2();Math.sign();Math.sinh();Math.tanh();Math.trunc(); |
| REMOVED polyfills in v3.8.0 | Array.prototype.values();Array.prototype.includes();String.prototype.includes();String.prototype.repeat();String.prototype[Symbol.iterator]();Object.assign();Object.entries();Object.values();Object.getOwnPropertyDescriptors();RegExp.prototype.flags;NodeList.prototype.forEach();ChildNode.after();ChildNode.before();ChildNode.remove();ChildNode.replaceWith();ParentNode.append();ParentNode.prepend();Element.prototype.matches();Element.prototype.closest();Element.prototype.toggleAttribute();Element.prototype.getAttributeNames();window.screenLeft;window.screenTop; |
| REMOVED polyfills in v5.6.0 | Array.prototype.at();Array.prototype.findLast();Array.prototype.findLastIndex();Array.prototype.flat();Array.prototype.flatMap();Number.MIN_SAFE_INTEGER;Number.MAX_SAFE_INTEGER;Object.fromEntries();Object.is();String.prototype.at();String.prototype.matchAll();String.prototype.padStart();String.prototype.padEnd();String.prototype.replaceAll();String.prototype.trimStart();String.prototype.trimLeft();String.prototype.trimEnd();String.prototype.trimRight();Typedarray.prototype.at();TypedArray.prototype.findLast();TypedArray.prototype.findLastIndex(); |
| REMOVED polyfills in v5.9.0 | BigInt.prototype.toJSON(); |
Samples
There are more samples in the unittest.js.
| Object name: "celestra" | alert( celestra.randomInt(100,200) ); |
|
| Object name: "CEL" | alert( CEL.randomInt(100,200) ); |
|
| VERSION | alert( CEL.VERSION ); |
domReady(fn) sample
CEL.domReady(function(){
CEL.qsa("p",CEL.qs("#div1")).forEach(function fn(el,i) {
el.style.color="red";
});
});
Testarea
p1
p2
div1 p3
div2
Samples
| domToElement(htmlString); |
|
|
| domCreate(type,properties,innerHTML); with style object | var el1 = CEL.domCreate("h3", {style: {"background-color": "lightblue", "font-weight": "bold"}}, "H3 Lorem ipsum with style object");
var el2 = CEL.domCreate("p", {}, "Sample created paragraph");
var el3 = CEL.domCreate("br");
var el4 = CEL.domCreate("a", {href: "https://developer.mozilla.org/en-US/", target: "_blank", style: { "background-color": "red", "color": "white"}}, "MDN Sample url");
CEL.qs("#div2").append(el1);
el2.append(el3);
el2.append(el4);
CEL.qs("#div2").append(el2); |
|
| domCreate(type,properties,innerHTML); with style string | var el1 = CEL.domCreate("h3", {style: {"background-color": "lightblue", "font-weight": "bold"}}, "H3 Lorem ipsum with style string");
var el2 = CEL.domCreate("p", {}, "Sample created paragraph");
var el3 = CEL.domCreate("br");
var el4 = CEL.domCreate("a", {href: "https://developer.mozilla.org/en-US/", target: "_blank", style: "background-color: red; color: white;"}, "MDN Sample url");
CEL.qs("#div2").append(el1);
el2.append(el3);
el2.append(el4);
CEL.qs("#div2").append(el2); |
|
| domCreate(object); with style object | var el1 = CEL.domCreate({elementType: "h3", style: {"background-color": "lightblue", "font-weight": "bold"}, innerHTML: "H3 Lorem ipsum from object with style object"});
var el2 = CEL.domCreate({elementType: "p", innerHTML: "Sample created paragraph"});
var el3 = CEL.domCreate("br");
var el4 = CEL.domCreate({elementType: "a", href: "https://developer.mozilla.org/en-US/", target: "_blank", style: {"background-color": "red", "color": "white"}, innerHTML: "MDN Sample url"});
CEL.qs("#div2").append(el1);
el2.append(el3);
el2.append(el4);
CEL.qs("#div2").append(el2); |
|
| domCreate(object); with styles string | var el1 = CEL.domCreate({elementType: "h3", style: {"background-color": "lightblue", "font-weight": "bold"}, innerHTML: "H3 Lorem ipsum from object with style string"});
var el2 = CEL.domCreate({elementType: "p", innerHTML: "Sample created paragraph"});
var el3 = CEL.domCreate("br");
var el4 = CEL.domCreate({elementType: "a", href: "https://developer.mozilla.org/en-US/", target: "_blank", style: "background-color: red; color: white;", innerHTML: "MDN Sample url"});
CEL.qs("#div2").append(el1);
el2.append(el3);
el2.append(el4);
CEL.qs("#div2").append(el2); |
|
| getUrlVars() | var params = CEL.getUrlVars(); |
|
| getUrlVars() found | alert( CEL.getUrlVars()["foo"] ); |
|
| getUrlVars() not found | alert( CEL.getUrlVars()["foobarbaznotfound"] ); |
|
| getUrlVars() with "?showall=true&order_by=updated&o=asc" | var params = CEL.getUrlVars(); |
|
| getUrlVars() found with "?testa=a1&testb=b2" | alert( CEL.getUrlVars("?showall=true&order_by=updated&o=asc")["order_by"] ); |
|
| getUrlVars() not found with "?testa=a1&testb=b2" | alert( CEL.getUrlVars("?showall=true&order_by=updated&o=asc")["notfound"] ); |
|
| getDoNotTrack() | alert( CEL.getDoNotTrack() ); |
|
| createFile(filename,content,dataType); |
Please check the downloaded files in your download folder!
|
|
| getLocation() |
|
|
| Fullscreen functions |
|
|
| domFade functions |
This is the fade test area. This is a span.
|
|
| domHide/Show/Toggle functions |
This is the hide/show/toggle test area. This is a span.
|
|
| domGetCSS and domSetCSS |
Testarea
|
|
| importStyle |
Testarea
|
|
| Cookie |
setCookie();
hasCookie();
getCookie(name);
getCookie();
removeCookie();
Test Code: var cookieTestStr = "✓ à \r\n\t árvíztűrő tükörfúrógép ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP ,?;.:-_* ¤÷ר¸´˙`˛°˘^ˇ~'+!%/=()|\\ \" \/ # & @{}[]€ ÍÄíŁß 0123456789 asdhjklqweuioyxcbnm ASDHJKLQWEUIOYXCBNM \u00E0\u00E8\u00EC\u00F2\u00F9";
var cookiestr = "";
cookiestr += "\ndocument.cookie: \""+document.cookie+"\"";
CEL.setCookie("ctest1",cookieTestStr);
CEL.setCookie("ctest2",cookieTestStr);
cookiestr += "document.cookie: \""+document.cookie+"\"";
cookiestr += "\n"+(CEL.getCookie("ctest1"))+" - (cookie value)"; // cookie value
cookiestr += "\n"+(CEL.getCookie("ctest2"))+" - (cookie value)"; // cookie value
cookiestr += "\n"+(CEL.getCookie())+" - (object)"; // object
cookiestr += "\n"+(CEL.getCookie()["ctest1"])+" - (object value ctest1)"; // object value ctest1
cookiestr += "\n"+(CEL.getCookie()["ctest2"])+" - (object value ctest2)"; // object value ctest2
cookiestr += "\n"+(CEL.hasCookie("ctest1"))+" - (true)"; // true
cookiestr += "\n"+(CEL.hasCookie("ctest2"))+" - (true)"; // true
cookiestr += "\n"+(CEL.removeCookie("ctest1"))+" - (true)"; // true
cookiestr += "\n"+(CEL.hasCookie("ctest1"))+" - (false)"; // false
cookiestr += "\n"+(CEL.hasCookie("ctest2"))+" - (true)"; // true
cookiestr += "\ndocument.cookie: \""+document.cookie+"\"";
cookiestr += "\n"+(CEL.removeCookie("ctest1"))+" - (false)"; // false
cookiestr += "\n"+(CEL.removeCookie("ctest2"))+" - (true)"; // true
cookiestr += "\n"+(CEL.hasCookie("ctest1"))+" - (false)"; // false
cookiestr += "\n"+(CEL.hasCookie("ctest2"))+" - (false)"; // false
cookiestr += "\ndocument.cookie: \""+document.cookie+"\"";
cookiestr += "\n"+(CEL.removeCookie("ctest1"))+" - (false)"; // false
cookiestr += "\n"+(CEL.removeCookie("ctest2"))+" - (false)"; // false
cookiestr += "\n"+(CEL.hasCookie("ctest1"))+" - (false)"; // false
cookiestr += "\n"+(CEL.hasCookie("ctest2"))+" - (false)"; // false
CEL.qs("#cookieresults").innerHTML = cookiestr;
Test results: cookieresults |
|
License
https://opensource.org/licenses/MIT
MIT License
SPDX short identifier: MIT
Copyright (c) 2017 Ferenc Czigler
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.