New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

dedupe-chars

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dedupe-chars

Removes duplicate characters from a string, preserving order

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

dedupe-chars

Canonical URL:
https://alexstevovich.com/a/dedupe-chars-nodejs

Software URL:
https://midnightcitylights.com/software/dedupe-chars-nodejs

A simple utility to remove duplicate characters from a string while preserving the order of their first occurrence.

Installation

npm install dedupe-chars

Example

import dedupeChars from 'dedupe-chars';

console.log(dedupeChars('aaabbbccc')); // "abc"
console.log(dedupeChars('hello world')); // "helo wrd"

Function

dedupeChars(input)

Removes duplicate characters from a string, preserving order.

Parameter

NameTypeDescription
inputstringThe input string to process.

Returns

TypeDescription
stringA new string with duplicate characters removed.

Notes

  • The function preserves the order of characters as they first appear.
  • Lightweight and efficient, using a Set to track seen characters.
  • Ideal for data normalization, text processing, and cleaning strings.

License

Licensed under the Apache License 2.0.

Keywords

string

FAQs

Package last updated on 12 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts