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

ts-cliche-unions

v1.3.2

Published

npm library for typescript

Downloads

25

Readme

Open in Visual Studio Code ts-cliche-unions_MIT ts-cliche-unions_npm_v

ts-cliche-unions

A module for writing JavaScript cliché strings safely in TypeScript.
It provides string constants for key, event, HTML element, and HTML attributes.
This module does not use enums, so unnecessary code is reduced by treeshaking when compiled.

Install

npm install ts-cliche-unions --save

Usage

Import this module into your TypeScript file.

import { KEY } from 'ts-cliche-unions';

This module can be used to replace key name strings, etc., with constants.

// if(ev.key === 'Enter') { ... }
if(ev.key === KEY.Enter) { ... }
// document.addEventListener('copy', (e) => { ... }  
document.addEventListener(EVENT.Copy, (e) => { ... }  
// const link = document.createElement("a");  
const link = document.createElement(ELEMENT.A);
// element.setAttribute('class','test');
element.setAttribute(ATTRIBUTE.Class, 'test');

Remarks

Supported Browsers

This module does not support the following versions of browsers.

  • Windows
    Chrome (version 48 or lower)

  • Mac
    Chrome (version 52 or lower)
    FireFox (version 48 or lower)

  • Linux
    Chrome (version 52 or lower)

Specification Notes

The library provides not only constants but also union types for constants, but the types support only alphabetic characters.
Be careful when using the library's union type for variables that may contain any character.

If you just want to use constants, don't worry about the above.

Contributing

If you find a bug or data that has not been updated, please send a pull request with the fix or open an issue!

Inspiration

ts-cliche-unions was inspired by Nathan Friend's ts-key-enum.

License

MIT