Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
printable-characters
Advanced tools
A little helper for handling strings containing zero width control characters, ANSI styling, whitespaces, newlines, 💩, etc.
A little helper for handling strings containing zero width characters, ANSI styling, whitespaces, newlines, weird Unicode 💩 symbols, etc.
const { strlen } = require ('printable-characters')
strlen ('foo bar') // === 7
strlen ('\u001b[106mfoo bar\u001b[49m') // === 7
const { isBlank } = require ('printable-characters')
isBlank ('foobar') // === false
isBlank ('\u001b[106m \t \t \n \u001b[49m') // === true
const { blank } = require ('printable-characters')
blank ('💩') // === ' '
blank ('foo') // === ' '
blank ('\tfoo \nfoo') // === '\t \n '
blank ('\u001b[22m\u001b[1mfoo \t\u001b[39m\u001b[22m')) // === ' \t'
const { ansiEscapeCodes, zeroWidthCharacters } = require ('printable-characters')
const s = '\u001b[106m' + 'foo' + '\n' + 'bar' + '\u001b[49m'
s.replace (ansiEscapeCodes, '') // === 'foo\nbar'
.replace (zeroWidthCharacters, '') // === 'foobar'
Use for safely truncating strings to maximum width without breaking ANSI codes:
const { first } = require ('printable-characters')
const s = '\u001b[22mfoobar\u001b[22m'
first (s, 0) // === '\u001b[22m\u001b[22m'
first (s, 1) // === '\u001b[22mf\u001b[22m'
first (s, 3) // === '\u001b[22mfoo\u001b[22m'
first (s, 6) // === '\u001b[22mfoobar\u001b[22m'
const { partition } = require ('printable-characters')
partition ('') // [ ])
partition ('foo') // [['', 'foo'] ])
partition ('\u001b[1mfoo') // [['\u001b[1m', 'foo'] ])
partition ('\u001b[1mfoo\u0000bar') // [['\u001b[1m', 'foo'], ['\u0000', 'bar'] ])
partition ('\u001b[1mfoo\u0000bar\n') // [['\u001b[1m', 'foo'], ['\u0000', 'bar'], ['\n', '']])
console.log
for the log-driven debugging junkies!Handle multi-component emojis, as in this article:
assert.equal (strlen ('👩❤️💋👩'), 1) // FAILING, see http://blog.jonnew.com/posts/poo-dot-length-equals-two for possible solution
assert.equal (blank ('👩❤️💋👩'), ' ') // FAILING, see http://blog.jonnew.com/posts/poo-dot-length-equals-two for possible solution
FAQs
A little helper for handling strings containing zero width control characters, ANSI styling, whitespaces, newlines, 💩, etc.
The npm package printable-characters receives a total of 1,081,318 weekly downloads. As such, printable-characters popularity was classified as popular.
We found that printable-characters 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.