Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
transliteration
Advanced tools
Transliteration module for node.js. Transliterate unicode characters into latin ones. Supports all common unicode characters including CJK.
The 'transliteration' npm package provides utilities for converting text between different scripts, particularly useful for converting non-Latin scripts to Latin scripts. It supports various transliteration schemes and can handle a wide range of languages.
Basic Transliteration
This feature allows you to convert text from non-Latin scripts to Latin scripts. In this example, Chinese characters are transliterated to their Latin equivalents.
const { transliterate } = require('transliteration');
const text = '你好,世界';
const result = transliterate(text);
console.log(result); // Output: 'Ni Hao , Shi Jie'
Slugify
This feature converts text into a URL-friendly slug. It is particularly useful for creating SEO-friendly URLs from non-Latin scripts.
const { slugify } = require('transliteration');
const text = '你好,世界';
const result = slugify(text);
console.log(result); // Output: 'ni-hao-shi-jie'
Custom Transliteration
This feature allows you to define custom mappings for transliteration. In this example, specific Cyrillic characters are mapped to their Latin equivalents.
const { transliterate } = require('transliteration');
const text = 'Привет, мир';
const customMap = { 'и': 'i', 'е': 'e', 'в': 'v' };
const result = transliterate(text, { customMap });
console.log(result); // Output: 'Privet, mir'
The 'transliterator' package provides similar functionality for converting text between different scripts. It supports a wide range of languages and offers customizable transliteration schemes. Compared to 'transliteration', it may offer more flexibility in defining custom rules.
The 'unidecode' package is another alternative for transliterating Unicode text to ASCII. It is particularly known for its simplicity and ease of use. However, it may not support as many languages or offer as much customization as 'transliteration'.
The 'diacritics' package focuses on removing diacritical marks from text, converting it to a simpler form. While it doesn't offer full transliteration capabilities, it is useful for normalizing text. It is more specialized compared to 'transliteration'.
Transliteration module for node.js. Transliterate unicode characters into latin ones. Supports all common unicode characters including CJK.
Transliterate str
. Unknown characters will be converted to unknown
Example
var transliteration = require('transliteration');
transliteration.transliterate('你好,世界'); // Ni Hao ,Shi Jie
Convert unicode string to slugs. It can be savely used in URL or file name.
You can provide an options
parameter in the form of
{
lowercase: true,
separator: '-'
}
Leave it blank to use the above default values.
Example
var transliteration = require('transliteration');
transliteration.slugify('你好,世界'); // ni-hao-shi-jie
transliteration.slugify('你好,世界', {lowercase: false, separator: '_'}); // Ni_Hao_Shi_Jie
FAQs
Unicode to ACSII transliteration / slugify module for node.js, browser, Web Worker, ReactNative and CLI.
The npm package transliteration receives a total of 201,242 weekly downloads. As such, transliteration popularity was classified as popular.
We found that transliteration demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.