
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
@types/punycode
Advanced tools
TypeScript definitions for punycode
@types/punycode provides TypeScript type definitions for the punycode library, which is used for encoding and decoding Unicode strings to and from the ASCII-compatible Punycode representation. This is particularly useful for handling internationalized domain names (IDNs).
Encode a Unicode string to Punycode
This feature allows you to encode a Unicode string into its Punycode representation. This is useful for converting internationalized domain names to a format that can be used in DNS queries.
const punycode = require('punycode');
const input = 'mañana';
const output = punycode.encode(input);
console.log(output); // 'maana-pta'
Decode a Punycode string to Unicode
This feature allows you to decode a Punycode string back into its original Unicode representation. This is useful for converting Punycode domain names back to their readable form.
const punycode = require('punycode');
const input = 'maana-pta';
const output = punycode.decode(input);
console.log(output); // 'mañana'
Convert a domain name to ASCII
This feature converts a Unicode domain name to its ASCII-compatible Punycode representation. This is useful for preparing internationalized domain names for DNS resolution.
const punycode = require('punycode');
const input = 'mañana.com';
const output = punycode.toASCII(input);
console.log(output); // 'xn--maana-pta.com'
Convert a domain name to Unicode
This feature converts a Punycode domain name back to its Unicode representation. This is useful for displaying internationalized domain names in a readable format.
const punycode = require('punycode');
const input = 'xn--maana-pta.com';
const output = punycode.toUnicode(input);
console.log(output); // 'mañana.com'
The idna-uts46-hx package provides similar functionality for handling internationalized domain names (IDNs) by implementing the UTS #46 standard. It offers more comprehensive handling of IDNs compared to punycode, including normalization and validation.
npm install --save @types/punycode
This package contains type definitions for punycode (https://mths.be/punycode).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/punycode.
These definitions were written by Dmitry Guketlev.
FAQs
TypeScript definitions for punycode
The npm package @types/punycode receives a total of 0 weekly downloads. As such, @types/punycode popularity was classified as not popular.
We found that @types/punycode 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.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.