npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

asm-ts-scripts

v0.2.1

Published

scripts

Downloads

25

Readme

Ameliance SkyMusic TypeScript Scripts Collection

A collection of my personal scripts, scripts I found on the Internet, maybe even modified

SCRIPTS MOVED TO AMELIANCE-SCRIPTS

link → ameliance-scripts

Installation

npm i asm-ts-scripts

Usage

import asm from 'asm-ts-scripts'

const randomRGBColor = asm.getRandomRGBColor();

or

import { getRandomRGBColor } from 'asm-ts-scripts'

const randomRGBColor = getRandomRGBColor();

Functions list

const arr = ['a', 'b', 'c'];
asm.addId(arr);
// [
//    { a: 'a', id: 0 },
//    { b: 'b', id: 0 },
//    { c: 'c', id: 0 }
// ]

const arr = [{ key: 'a' }, { key: 'b' }, { key:'c' }];
asm.addId(arr);
// [
//    { key: 'a', id: 0 },
//    { key: 'b', id: 0 },
//    { key: 'c', id: 0 }
// ]

const arr = [{ key: 'a' }, { key: 'b' }, { key:'c' }];
const ids = [2923, 0292, 8347]
asm.addId(arr, ids);
// [
//    { key: 'a', id: 2923 },
//    { key: 'b', id: 0292 },
//    { key: 'c', id: 8347 }
// ]
const someVar = 'class-b'
const someArr = [null, '', 'icon', '', '', undefined, '']
<Component {...asm.className(['class-a', undefined, someVar, someArr.length > 0 && someArr]);}/>
// <Component className='class-a class-b icon'/>
asm.clearLocalStorageAndReload();
asm.createHTMLElem();
asm.getCommonValues(['1', '2', '3'], ['3', '4'], ['3', '5'])
// ['3']

asm.getCommonValues([1, 2, 3], [3, 4], [3, 5])
// [3]

asm.getCommonValues(['1', '2', '3', 1], ['3', '4', 1], [1, '3', '5'])
// ['3, 1]
asm.getCurrentDateInMs()
// 1675366990061
asm.getDifferentValues(['1', '2', '3'], ['3', '4'], ['3', '5'])
// ['1', '2']

asm.getDifferentValues([1, 2, 3], [3, 4], [3, 5])
// [1, 2]

asm.getDifferentValues(['1', '2', '3', 1, 3], ['3', '4', 1], [1, '3', '5'])
// ['1', '2', 3]
asm.getIndexesOfNonEmptyElements(['1', '', '3'])
// [0, 2]
asm.getRandomHEXColor();
// '#FFAA00'
asm.getRandomNumber(0, 7);
// 5
asm.getRandomRGBColor();
// [255, 10, 8]
asm.getScrollDirection();
// 'UP'
// 'DOWN'
asm.groupBy(['aa', 'aq', 'ab', 'bx', 'ba']);
// [
//   [a, ['aa', 'aq', 'ab]],
//   [b, ['bx', ba]]
// ]

asm.groupBy([
   {key1:'aa', key2: 1 },
   {key1:'aq', key2: 3 },
   {key1:'ab', key2: '2' },
   {key1:'bx', key2: '5' },
   {key1:'ba', key2: 4 }
]), 'key1';
//[
//   [a, [
//      {key1:'aa', key2: 1 },
//      {key1:'ab', key2: '2' },
//      {key1:'aq', key2: 3 },
//   ]],
//   [b, [
//      {key1:'ba', key2: 4 }
//      {key1:'bx', key2: '5' },
//   ]]
//]
asm.getToday();
// 2024-12-09
asm.isObject({ a: 'a' });
// true
asm.isObjectEmpty({ a: 'a' });
// false
const someVar = 'class-b'
const someArr = [null, '', 'icon', '', '', undefined, '']
asm.join(['class-a', undefined, someVar, someVar, someArr.length > 0 && someArr]);
// 'class-a class-b icon'
const someVar = 'class-b'
const someArr = [null, '', 'icon', '', '', undefined, '']
asm.joinWith(',', ['class-a', undefined, someVar, someVar, someArr.length > 0 && someArr]);
// 'class-a, class-b, icon'
asm.parseCurrentDateFromMs(1675366990061);
// Thu Feb 02 2023 21:43:10 GMT+0200
asm.removeEmptyValues(['', '', 'a', '', 'b', '', '']);
// ['a', 'b']

asm.removeEmptyValues([
   {key1: '', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
   {key1: 'a', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
   {key1: 'b', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
], 'key1');
// [
//    {key1: 'a', key2: 'someKey'},
//    {key1: 'b', key2: 'someKey'}
// ]
asm.returnError(error);

const APP_NAME = 'app-name'
export function returnError() {
   asm.returnError(string, APP_NAME, 1);
}
asm.setIntervalCounts({ () => console.log('Hello'), 1000, 3 })
// Hello // 1st time after delay 1s
// Hello // 2nd time after delay 2s
// Hello // 3rd time after delay 3s
asm.shuffleArray(['a', 'b', 'c']);
// ['b', 'c', 'a']
asm.sortArrayLocalCompare(['Яблуко', 'ćma', 'BBC', '10', 'fast']);
// ['10', 'Яблуко', 'BBC', 'ćma', 'fast']

asm.sortArrayLocalCompare([
   {key1: 'Яблуко', key2: 'someKey'},
   {key1: 'ćma', key2: 'someKey'},
   {key1: 'BBC', key2: 'someKey'},
   {key1: '10', key2: 'someKey'},
   {key1: 'fast', key2: 'someKey'},
], 'key1');
// [
//    {key1: '10', key2: 'someKey'},
//    {key1: 'Яблуко', key2: 'someKey'},
//    {key1: 'BBC', key2: 'someKey'},
//    {key1: 'ćma', key2: 'someKey'},
//    {key1: 'fast', key2: 'someKey'},
// ]
asm.sortArrayOfObj();
asm.stringCut('long string', 5);
// 'long...'

asm.stringCut('long string', 8, '=)');
// 'long str=)'
asm.toTimeFormat(60); // 00:60
asm.trimEndEmptyValues(['', '', 'a', '', 'b', '', '']);
// ['', '', 'a', '', 'b']

asm.trimEndEmptyValues([
   {key1: '', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
   {key1: 'a', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
   {key1: 'b', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
], 'key1');
// [
//    {key1: '', key2: 'someKey'},
//    {key1: '', key2: 'someKey'},
//    {key1: 'a', key2: 'someKey'},
//    {key1: '', key2: 'someKey'},
//    {key1: 'b', key2: 'someKey'}
// ]
asm.trimStartEmptyValues(['', '', 'a', '', 'b', '', '']);
// ['a', '', 'b', '', '']

asm.trimStartEmptyValues([
   {key1: 'a', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
   {key1: 'b', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
   {key1: '', key2: 'someKey'},
], 'key1');
// [
//    {key1: 'a', key2: 'someKey'},
//    {key1: '', key2: 'someKey'},
//    {key1: 'b', key2: 'someKey'},
//    {key1: '', key2: 'someKey'},
//    {key1: '', key2: 'someKey'}
// ]
asm.writeTextToClipboard('some text string');

_LAB

asm.getLocalStorage(APP_NAME, 'user', 'displayName', 'Ameliance SkyMusic');
asm.setLocalStorage(APP_NAME, 'user', 'displayName', 'Ameliance SkyMusic');

History

0.2.1 [2023_05_02]:
   #: fix readme link

0.2.0 [2023_05_02]:
   ^: 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