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

frotsi

v1.4.43

Published

This package should not be taken very seriously BUT it does provide many useful features.

Downloads

19

Readme

✨FROTSI - Frontend TS Library ✨

Extra Stuff for Frontend Development!

This package should not be taken very seriously BUT it does provide many useful features.

Frotsi provides basic extensions for Math, Promise, String, Array globals objects. Besides that it adds some additional utils for various areas. All these functions will amp your work on building components/views/custom-html-elements etc.

Features

Functions

  • Extending JS.Math with functions: randomInt
  • Extending JS.Array with functions: sortNumbers, popRandom, random, last, symmetricDifference
  • Extending JS.Promise with functions: fireAndForget
  • Providing functions related to generating random IDs: generateInputId (useful for html inputs), generateDocumentId
  • loop iterator so you don't have to iterate over unfilled Arrays anymore
  • LocalStorage opinionated wrapper

Types

  • Flatten - Takes a type T and tries to flatten its type hierarchy by combining all of its properties into a single, non-nested type. Borrowed from TypeScript Grand Wizard Matt Pocock @mattpocock (he calls it Prettify, see here: https://www.youtube.com/watch?v=2lCCKiWGlC0 ).
  • DeepFlatten - Does what Flatten sometimes can't in more complicated and nested object types.

Installation / Import

After installing it with npm you should import the library at the top of your project's main (root) JS/TS file, so the global object extensions can attach themselves. For example in Angular it would be main.ts, in React main.tsx:

import 'frotsi';
import ...
...

Usage

After installing and importing, use it anywhere in your app, like so:

MATH:
Math.randomInt(1, 2);                               // --> '1' OR '2'

ARRAY:
[13,67,4,24,566].sortNumbers();                     // --> '[4, 13, 24, 67, 566]'
[1, 2, 3].random();                                 // --> get one item from provided array
[1, 2, 3].random(2);                                // --> get two item from provided array
[1, 2, 3].popRandom();                              // --> pop one item from provided array
[1, 2, 3].symmetricDifference([1, 2, 3, 3, 4]);     // --> '{ diffBase: [], diffCompared: [4] }'

PROMISE:
new Promise( ... ).fireAndForget();                 // --> 'undefined' - simply fires a Promise
new Promise( ... ).fireAndForget(true);             // --> 'undefined' - simply fires a Promise + logs errors

OTHER:
generateInputId('select', 'project-role');          // --> '@id_4796_5196_input_select_data_project-role'
generateDocumentId();                               // --> '20230525_022358_902Z_420'
loop(5).forEach(index => { ... });                  // --> 'undefined' - loops 5 times
loop(5).map(index => ({index: `${index}`}));        // --> '{index: string}[]' - loop 5 times and returns 5-element typed array
LocalStorage.setItem(`user`, {user: 'John'})