https://github.com/igorskyflyer/npm-zing
π Zing is a C# style String formatter for JavaScript that empowers Strings with positional arguments - composite formatting. π
https://github.com/igorskyflyer/npm-zing
back-end biome c-style cs csharp formatter igorskyflyer javascript js npm print printf string system utility vitest zing
Last synced: 4 months ago
JSON representation
π Zing is a C# style String formatter for JavaScript that empowers Strings with positional arguments - composite formatting. π
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-zing
- Owner: igorskyflyer
- License: mit
- Created: 2022-08-18T02:40:30.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-10T22:56:05.000Z (about 2 years ago)
- Last Synced: 2025-03-07T20:48:47.202Z (over 1 year ago)
- Topics: back-end, biome, c-style, cs, csharp, formatter, igorskyflyer, javascript, js, npm, print, printf, string, system, utility, vitest, zing
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@igor.dvlpr/zing
- Size: 82 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Zing
π Zing is a C# style String formatter for JavaScript that empowers Strings with positional arguments - composite formatting. π
## π Table of Contents
- [Features](#-features)
- [Usage](#-usage)
- [API](#-api)
- [Changelog](#-changelog)
- [Support](#-support)
- [License](#-license)
- [Related](#-related)
- [Author](#-author)
## π€ Features
- β‘ Quick formatting - Drop in `{0}`, `{1}` placeholders and swap them instantly
- π C#-style syntax - Familiar composite formatting for .NET devs in JS/TS
- π― Positional arguments - Control exactly where each value lands
- π‘ Safe fallback - Leaves unknown placeholders untouched
- π§© Lightweight utility - No dependencies, minimal footprint
- π Multi-replace - Handles all matching placeholders in one pass
- π TypeScript-ready - Strong typing for cleaner code
- π Cross-platform - Works in browser and Node environments
> βΉοΈ **NOTE**
>
> More information about [composite formatting](https://docs.microsoft.com/en-us/dotnet/standard/base-types/composite-formatting).
>
## π΅πΌ Usage
Install it by executing any of the following, depending on your preferred package manager:
```bash
pnpm add @igorskyflyer/zing
```
```bash
yarn add @igorskyflyer/zing
```
```bash
npm i @igorskyflyer/zing
```
## π€ΉπΌ API
```ts
zing(value: string, ...args: any[]): string
```
Formats the provided string in a C# style format, i.e. adds the ability to use positional arguments, like seen with `String.Format` in C#.
`value: string` => The string to process that support positional parameters, i.e. `zing('Hello {0} {1}', 'Igor', 'DimitrijeviΔ')` would output `Hello Igor DimitrijeviΔ`.
The returned value is always a `string`.
## π Changelog
π The changelog is available here, [CHANGELOG.md](https://github.com/igorskyflyer/npm-zing/blob/main/CHANGELOG.md).
## πͺͺ License
Licensed under the MIT license which is available here, [MIT license](https://github.com/igorskyflyer/npm-zing/blob/main/LICENSE).
## π Support
I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. β
Thank you for supporting my efforts! ππ
## 𧬠Related
[@igorskyflyer/recursive-readdir](https://www.npmjs.com/package/@igorskyflyer/recursive-readdir)
> _π Provides recursive readdir() and readdirSync() functions. π_
[@igorskyflyer/regkeys](https://www.npmjs.com/package/@igorskyflyer/regkeys)
> _π An npm package for fetching Windows registry keys. π_
[@igorskyflyer/jmap](https://www.npmjs.com/package/@igorskyflyer/jmap)
> _πΆοΈ Reads a JSON file into a Map. π»_
[@igorskyflyer/unc-path](https://www.npmjs.com/package/@igorskyflyer/unc-path)
> _π₯½ Provides ways of parsing UNC paths and checking whether they are valid. π±_
[@igorskyflyer/scrollend-polyfill](https://www.npmjs.com/package/@igorskyflyer/scrollend-polyfill)
> _π΄ A performant and light (< 1KB) JavaScript polyfill for the scrollend Event. βΈοΈ_
## π¨π»βπ» Author
Created by **Igor DimitrijeviΔ** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).