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

@hisorange/elastring

v1.1.2

Published

Fluent immutable string transformations

Downloads

758

Readme

ElaString Logo

ElaString - Fluent Immutable String Transformation

Version Build Coverage Status GitHub license

Opionated fluent string transformations; You can use this package when the input is coming from a user or any other unregulated source, and you want to use the string in a normalized and formated way.

Getting Started


npm i @hisorange/elastring
# or
yarn add @hisorange/elastring

Examples


import { Elastring } from '@hisorange/elastring';

const str = new Elastring('ORMDriver');

console.log(str.snakeCase.toString()); // orm_driver
console.log(str.pascalCase.suffix('.html').toString()); // OrmDriver.html
console.log(str.upperCase.toString()); // ORMDRIVER
console.log(`${str.pathCase.prefix('../').suffix('.js')} at!`); // ../orm/driver.js at!

Transformations


| Fun | Input | Output | Normalized | | -------------------- | ----------------------- | ------------ | :--------: | | singular | child | children | x | | pascalCase | ela-string | ElaString | x | | plural | children | child | ✓ | | camelCase | ela string | elaString | ✓ | | kebabCase | ElaString | ela-string | ✓ | | snakeCase | ElaString | ela_string | ✓ | | dotCase | ElaString | ela.string | ✓ | | humanCase | ela_string | Ela string | ✓ | | titleCase | ela_string | Ela String | ✓ | | upperCase | ela_string | ELA_STRING | x | | lowerCase | ELA_STRING | ela_string | x | | capitalCase | ela string | Ela-string | x | | vacuumCase | ela string | elastring | x | | pathCase | ela string | ela/string | ✓ | | prefix() | string.prefix('ela') | elastring | x | | suffix() | ela.suffix('string.js') | elastring.js | x | | stripExtension() | elastring.js | elastring | x | | reverse | elastring | gnirtsale | x |

Technicalities


TypeScript: Everything is written in typescript from the get go, so You can have the best DX possible :)

Normalization: Some transformer will normalize the string first, this is there to avoid the weird side effects of some format to format conversion.

Immutable: After initialization the strings are immutable, so every call will create a new instance with the expected format, this is useful behavior when a string need in multiple format but be aware this is a computation heavy solution, so it's not advised to be used a in a high performance demanding environments.

Versioning: SemVer! But be aware if there is a behavior change then it will break compatibility so the major release will be changed, currently running ~110 test to ensure consistency but there are always edge cases, so each edge case will be fixed with a major release to avoid ruining someones setup on that case.

Links


Changelog


1.1.x
  • Added the reverse transformation
  • Fixed the terrible readme mesh :v
1.0.0 - Initial Release