Gathering detailed insights and metrics for ameliance-scripts
Gathering detailed insights and metrics for ameliance-scripts
Gathering detailed insights and metrics for ameliance-scripts
Gathering detailed insights and metrics for ameliance-scripts
npm install ameliance-scripts
Typescript
Module System
Node Version
NPM Version
TypeScript (98.52%)
JavaScript (1.28%)
Shell (0.21%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
45 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Apr 21, 2025
Latest Version
0.4.108
Package Id
ameliance-scripts@0.4.108
Unpacked Size
175.23 kB
Size
44.83 kB
File Count
9
NPM Version
11.2.0
Node Version
22.13.1
Published on
Apr 21, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
7
A collection of my personal scripts, scripts I found on the Internet, maybe even modified
npm i ameliance-scripts
Import like this
1import { getRandomRGBColor } from "ameliance-scripts"; 2 3const randomRGBColor = getRandomRGBColor();
or
1import a from "ameliance-scripts"; 2 3const randomRGBColor = getRandomRGBColor();
1const arr = ["a", "b", "c"]; 2addId(arr); 3// [ 4// { a: 'a', id: 0 }, 5// { b: 'b', id: 0 }, 6// { c: 'c', id: 0 } 7// ] 8 9const arr = [{ key: "a" }, { key: "b" }, { key: "c" }]; 10addId(arr); 11// [ 12// { key: 'a', id: 0 }, 13// { key: 'b', id: 0 }, 14// { key: 'c', id: 0 } 15// ] 16 17const arr = [{ key: "a" }, { key: "b" }, { key: "c" }]; 18const ids = [2923, 0292, 8347]; 19addId(arr, ids); 20// [ 21// { key: 'a', id: 2923 }, 22// { key: 'b', id: 0292 }, 23// { key: 'c', id: 8347 } 24// ]
1const someVar = 'class-b' 2const someArr = [null, '', 'icon', '', '', undefined, ''] 3<Component {...className(['class-a', undefined, someVar, someArr.length > 0 && someArr]);}/> 4// <Component className='class-a class-b icon'/>
1clearLocalStorageAndReload();
1createHTMLElem();
1detectValueType("some string"); 2// 'string' 3 4detectValueType(123); 5// 'number' 6 7detectValueType(true); 8// 'boolean' 9 10detectValueType(new Date()); 11// 'date'
1const unsafeStringWithInjection = 'Hello <script>alert("XSS")</script>!'; 2escapeHtml(unsafeStringWithInjection); 3//"Hello <script>alert("XSS")</script>!"
1errorHandler(error);
2
3export function handleAppError(error: unknown, code?: number): ReturnError {
4 return errorHandler({
5 error,
6 code,
7 errorTitle: process.env.APP_NAME,
8 wrapperCount: 1,
9 });
10}
11
12// '{status: 520, message: "Unknown Error", code?: "UNKNOWN_ERROR" }';
1const originalObject = { a: 1, b: 2, c: 3 }; 2const updatedObject = { a: 2, b: 2, d: 5 }; 3getChangedProperties(obj1, obj2); 4// { a:2, c: 3, d: 5 }
1getCommonValues(["1", "2", "3"], ["3", "4"], ["3", "5"]); 2// ['3'] 3 4getCommonValues([1, 2, 3], [3, 4], [3, 5]); 5// [3] 6 7getCommonValues(["1", "2", "3", 1], ["3", "4", 1], [1, "3", "5"]); 8// ['3', 1]
1getCurrentDateInMs(); 2// 1675366990061
1getDifferentValues(["1", "2", "3"], ["3", "4"], ["3", "5"]); 2// ['1', '2'] 3 4getDifferentValues([1, 2, 3], [3, 4], [3, 5]); 5// [1, 2] 6 7getDifferentValues(["1", "2", "3", 1, 3], ["3", "4", 1], [1, "3", "5"]); 8// ['1', '2', 3]
1const arr = [ 2 { a: 1, b: 2 }, 3 { a: 3, b: 4 }, 4 { a: 3, b: 2 }, 5]; 6getElemByKey(arr, a, 3); 7// { a: 3, b: 4 }
1getFormattedDate("2023-06-01"); 2// June 1, 2023 3 4getFormattedDate("2023-06-01", "short"); 5// 6/1/23 6 7getFormattedDate("2023-06-01", "full", "uk-UA"); 8// четвер, 1 червня 2023 р. 9 10getFormattedDate("2023-06-01", "full", "ja-JP"); 11// 2023年6月1日木曜日
1const arr = [ 2 { a: 1, b: 2 }, 3 { a: 3, b: 4 }, 4 { a: 3, b: 2 }, 5]; 6getIndexByKey(arr, a, 3); 7// 2
1getIndexesOfNonEmptyElements(["1", "", "3"]); 2// [0, 2]
1const code = 999; 2getMatchSoft(code, { 3 403: "Forbidden ", 4 500: "Server Error", 5 _: "Unknown error", 6}); 7// "Unknown error" 8 9const code = 999; 10getMatchSoft(code, { 11 403: "Forbidden ", 12 500: "Server Error", 13 _: "Unknown error", 14}); 15// null
1const code = 403; 2getMatch(code, { 3 403: "Forbidden ", 4 500: "Server Error", 5 _: "Unknown error", 6}); 7// Forbidden
1getObjKeyByValue();
1getRandomHEXColor(); 2// '#FFAA00'
1getRandomNumber(0, 7); 2// 5
1getRandomRGBColor(); 2// [255, 10, 8]
1getScrollDirection(); 2// 'UP' 3// 'DOWN'
1getToday(); 2// 2024-12-09
1getValueType("some string"); 2// 'string' 3 4getValueType(123); 5// 'number'
1groupBy(["aa", "aq", "ab", "bx", "ba"]); 2// [ 3// [a, ['aa', 'aq', 'ab]], 4// [b, ['bx', ba]] 5// ] 6 7groupBy([ 8 { key1: "aa", key2: 1 }, 9 { key1: "aq", key2: 3 }, 10 { key1: "ab", key2: "2" }, 11 { key1: "bx", key2: "5" }, 12 { key1: "ba", key2: 4 }, 13]), 14 "key1"; 15//[ 16// [a, [ 17// {key1:'aa', key2: 1 }, 18// {key1:'ab', key2: '2' }, 19// {key1:'aq', key2: 3 }, 20// ]], 21// [b, [ 22// {key1:'ba', key2: 4 } 23// {key1:'bx', key2: '5' }, 24// ]] 25//]
1hideEmail("ameliaceskymusic@gmail.com"); 2// a***************c@gmail.com
1const en = { 2 helloMessage: "Hello {{user.name}}, your age is {{user.age}}. Theme: {{theme}}.", 3}; 4 5interpolate(en.helloMessage, { 6 user: { 7 title: 'John <script>alert("XSS")</script>', 8 age: 30, 9 }, 10 theme: "dark", 11}); 12 13//"Hello John <script>alert("XSS")</script>, your age is 30. Theme: dark.
1isArraysEqual([1, 2, 3], [1, 2, 3]); 2// true 3 4isArraysEqual([1, 2, 3], [1, 2]); 5// false
1isClient(); // on client 2// true 3 4isClient(); // on server 5// false
1isObjectEmpty({ a: "a" }); 2// false
1isObjectHasValue({ a: "world", b: "hello" }, "react"); 2// false 3 4isObjectHasValue({ a: "world", b: "hello" }, "world"); 5// true
1isObjectValid("a"); 2// false 3isObjectValid(null); 4// false 5isObjectValid({}); 6// false 7isObjectValid({ a: "a" }); 8// true
1isObject({ a: "a" }); 2// true
1console.log(isValidUrl("https://example.com")); 2// true - a valid URL with a protocol 3 4console.log(isValidUrl("http://example.com")); 5// true - a valid URL with another protocol 6 7console.log(isValidUrl("ftp://example.com")); 8// true - a valid URL with the FTP protocol 9 10console.log(isValidUrl("www.example.com")); 11// false - missing protocol 12 13console.log(isValidUrl("example.com")); 14// false - missing protocol 15 16console.log(isValidUrl("")); 17// false - empty string 18 19console.log(isValidUrl("random_string")); 20// false - not a valid URL format 21 22console.log(isValidUrl("https://")); 23// false - protocol exists, but domain is missing 24 25console.log(isValidUrl("https://example.com/path?query=123")); 26// true - valid URL with a path and query parameters 27 28console.log(isValidUrl("https://example.com:8080")); 29// true - valid URL with a port 30 31console.log(isValidUrl("https://invalid_domain")); 32// true - technically valid format, but the domain looks suspicious
1joinWith(" ", ["a", "b", "c"]); 2// 'a b c' 3 4joinWith(", ", ["a", "b", "c", null, undefined]); 5// 'a, b, c' 6 7const someVar = "class-b"; 8const someArr = [null, "", "icon", "", "", undefined, ""]; 9joinWith(",", ["class-a", undefined, someVar, someVar, someArr.length > 0 && someArr]); 10// 'class-a, class-b, icon'
1const someVar = "class-b"; 2const someArr = [null, "", "icon", "", "", undefined, ""]; 3const someObj = { "active-class-name": false, "another-class": a === b }; 4join([ 5 "class-a", 6 undefined, 7 someVar, 8 someVar, 9 someArr.length > 0 && someArr, 10 someObj, 11 path === curPath && "active", 12]); 13// 'class-a class-b icon another-class'
1const someVar = "class-b"; 2const someArr = [null, "", "icon", "", "", undefined, ""]; 3const someObj = { "active-class-name": false, "another-class": a === b }; 4join([ 5 "class-a", 6 undefined, 7 someVar, 8 someVar, 9 someArr.length > 0 && someArr, 10 someObj, 11 path === curPath && "active", 12]); 13// 'class-a class-b icon another-class'
1kebabToCamelCase("some-class-name"); 2// someClassName
1log.warn( 2 errorTitle, 3 errorSubtitle, 4 new Error().stack?.split("\n").splice(errorCount, errorDeep).join("\n"), 5); 6 7log.error( 8 errorTitle, 9 [errorSubtitle, "background-color: red;"], 10 [`\n${new Error().stack?.split("\n").splice(errorCount, errorDeep).join("\n")}`, ""], 11);
1parseCurrentDateFromMs(1675366990061); 2// Thu Feb 02 2023 21:43:10 GMT+0200
1removeEmptyValues(["", "", "a", "", "b", "", ""]); 2// ['a', 'b'] 3 4removeEmptyValues( 5 [ 6 { key1: "", key2: "someKey" }, 7 { key1: "", key2: "someKey" }, 8 { key1: "a", key2: "someKey" }, 9 { key1: "", key2: "someKey" }, 10 { key1: "b", key2: "someKey" }, 11 { key1: "", key2: "someKey" }, 12 { key1: "", key2: "someKey" }, 13 ], 14 "key1", 15); 16// [ 17// {key1: 'a', key2: 'someKey'}, 18// {key1: 'b', key2: 'someKey'} 19// ]
1setIntervalCounts({ () => console.log('Hello'), 1000, 3 }) 2// Hello // 1st time after delay 1s 3// Hello // 2nd time after delay 2s 4// Hello // 3rd time after delay 3s
1shuffleArray(["a", "b", "c"]); 2// ['b', 'c', 'a']
1sortArrayLocalCompare(["Яблуко", "ćma", "BBC", "10", "fast"]); 2// ['10', 'Яблуко', 'BBC', 'ćma', 'fast'] 3 4sortArrayLocalCompare( 5 [ 6 { key1: "Яблуко", key2: "someKey" }, 7 { key1: "ćma", key2: "someKey" }, 8 { key1: "BBC", key2: "someKey" }, 9 { key1: "10", key2: "someKey" }, 10 { key1: "fast", key2: "someKey" }, 11 ], 12 "key1", 13); 14// [ 15// {key1: '10', key2: 'someKey'}, 16// {key1: 'Яблуко', key2: 'someKey'}, 17// {key1: 'BBC', key2: 'someKey'}, 18// {key1: 'ćma', key2: 'someKey'}, 19// {key1: 'fast', key2: 'someKey'}, 20// ]
1sortArrayOfObj();
1stringCut("long string", 5); 2// 'long...' 3 4stringCut("long string", 8, "=)"); 5// 'long str=)'
1toTimeFormat(60); // 00:60
1trimEndEmptyValues(["", "", "a", "", "b", "", ""]); 2// ['', '', 'a', '', 'b'] 3 4trimEndEmptyValues( 5 [ 6 { key1: "", key2: "someKey" }, 7 { key1: "", key2: "someKey" }, 8 { key1: "a", key2: "someKey" }, 9 { key1: "", key2: "someKey" }, 10 { key1: "b", key2: "someKey" }, 11 { key1: "", key2: "someKey" }, 12 { key1: "", key2: "someKey" }, 13 ], 14 "key1", 15); 16// [ 17// {key1: '', key2: 'someKey'}, 18// {key1: '', key2: 'someKey'}, 19// {key1: 'a', key2: 'someKey'}, 20// {key1: '', key2: 'someKey'}, 21// {key1: 'b', key2: 'someKey'} 22// ]
1trimStartEmptyValues(["", "", "a", "", "b", "", ""]); 2// ['a', '', 'b', '', ''] 3 4trimStartEmptyValues( 5 [ 6 { key1: "a", key2: "someKey" }, 7 { key1: "", key2: "someKey" }, 8 { key1: "b", key2: "someKey" }, 9 { key1: "", key2: "someKey" }, 10 { key1: "", key2: "someKey" }, 11 ], 12 "key1", 13); 14// [ 15// {key1: 'a', key2: 'someKey'}, 16// {key1: '', key2: 'someKey'}, 17// {key1: 'b', key2: 'someKey'}, 18// {key1: '', key2: 'someKey'}, 19// {key1: '', key2: 'someKey'} 20// ]
1writeTextToClipboard("some text string");
1lab.getLocalStorage(APP_NAME, "user", "displayName", "Ameliance SkyMusic");
1lab.setLocalStorage(APP_NAME, "user", "displayName", "Ameliance SkyMusic");
1legacy.join();
1legacy.returnError2();
1legacy.returnError1();
0.4.108 [2025-04-21]
+: escapeHtml
+: interpolate
0.4.107 [2025-03-27]:
*: update sortArrayOfObj
0.4.106 [2024_12_10]:
#: fix errorHandler message log
0.4.105 [2024_11_21]:
^: move useActiveClass script to library to https://www.npmjs.com/package/ameliance-react-scripts
0.4.0 [2024_11_18]:
^: move react scripts to library to https://www.npmjs.com/package/ameliance-react-scripts
*: rename get-random-hexcolor to get-random-hex-color
0.3.4 [2024_11_18]:
+: add detectValueType
+: add getChangedProperties
+: add getCurrentTimeWithOffset
+: add getMatchSoft
+: add getValueType
+: add isArraysEqual
+: add іsValidUrl
+: add kebabToCamelCase
+: add trimStartEmptyValues
*: update getMatch
*: update sortArrayOfObj
0.3.3 [2024_10_04]:
+: add log
#: add styles error-handler console.log
0.3.2 [2024_09_11]:
#: fix publish issues
0.3.1 [2024_09_11]:
*: update code style
0.3.0 [2024_09_10]:
+: add generate-response-json-error
+: add generate-response-json-success
^: update error-handler
*: rename return-error to error-handler
*: update function file names to kebab-case name convention
*: reorganize structure
*: migrate to use tsup bundler
#: fixes during migration to tsup
0.2.4 [2023_12_01]:
*: update returnError
+: add hideEmail
+: add isClient
+: add getElemByKey
+: add getIndexByKey
+: add getMatch
+: add splitTextByBr
+: add getObjKeyByValue
0.2.3 [2023_06_01]:
*: extend join function
+: add getFormattedDate
+: add isObjectHasValue
+: add isObjectValid
+: add useActiveClass
0.2.2 [2023_05_07]:
^: add deep fourth param to returnError
#: fix work with numbers groupBy
#: fix work with numbers removeEmptyValues
#: fix work with numbers sortArrayLocalCompare
0.2.1 [2023_05_02]:
*: update naming
0.2.0 [2023_05_02]:
^: rename and move library to https://www.npmjs.com/package/ameliance-scripts
0.1.104 [2023_05_02]:
+: add writeTextToClipboard
+: add toTimeFormat
+: add returnError
+: add joinWith
+: add getToday
+: add clearLocalStorageAndReload
+: add setLocalStorage to _LAB
+: add getLocalStorage to _LAB
*: update types anc add some improvements sortBy
*: update types anc add some improvements removeEmptyValues
*: update types anc add some improvements sortArrayLocalCompare
0.1.103 [2023_03_06]:
+: add addId
0.1.102 [2023_02_02]:
*: rename joinClasses to join
#: fix join
+: add className
+: add setIntervalCounts
+: add getCurrentDateInMs
+: add parseCurrentDateFromMs
0.1.101 [2023_01_02]:
#: fixes
0.1.1 [2023_01_02]:
+: add isObject
+: add getCommonValues
+: add removeEmptyValues
+: add getDifferentValues
+: add trimEndEmptyValues
+: add trimStartEmptyValues
+: add getIndexesOfNonEmptyElements
^: add support sorting objects in groupBy
^: add support sorting objects in sortArrayLocalCompare
*: rename combineListToSortedArray to groupBy
*: rename sortStringArrayLocalCompare to sortArrayLocalCompare
*: refactor code
0.0.107 [2022_12_22]:
^: update readme file
0.0.106 [2022_12_22]:
^: update readme file
0.0.105 [2022_12_22]:
#: fix export
^: update readme file
0.0.104 [2022_12_22]:
+: add sortStringArrayLocalCompare
#: fix stringCut
^: clean code
0.0.103 [2022_12_22]:
+: add combineListToSortedArray
#: fix joinClasses
0.0.102 [2022_12_17]:
^: update readme file
0.0.101 [2022_12_17]:
^: update readme file
0.0.100 [2022_12_17]:
+: add createHTMLElem
+: add getRandomHEXColor
+: add getRandomNumber
+: add getRandomRGBColor
+: add getScrollDirection
+: add isObjectEmpty
+: add joinClasses
+: add shuffleArray
+: add sortArrayOfObj
+: add stringCut
No vulnerabilities found.
No security vulnerabilities found.