Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shrink-string

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shrink-string - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

6

index.js

@@ -8,3 +8,3 @@ const { gzip, gunzip } = require('zlib')

const encode = async (s = '') => {
const compress = async (s = '') => {
const compressed = await gz(s)

@@ -14,3 +14,3 @@ return Buffer.from(compressed).toString('base64')

const decode = async (s = '') => {
const decompress = async (s = '') => {
const decompressed = await ugz(Buffer.from(Buffer.from(s, 'base64')))

@@ -21,3 +21,3 @@ return decompressed.toString()

module.exports = {
encode, decode
compress, decompress
}
const test = require('tape-async')
const { encode, decode } = require('.')
const { compress, decompress } = require('.')
test('shrink', async (t) => {
const s = 'asdf'.repeat(16)
const shrunk = await encode(s)
const expanded = await decode(shrunk)
const s = 'asdfλ'.repeat(16)
const shrunk = await compress(s)
const expanded = await decompress(shrunk)
t.equal(s, expanded)
t.true(shrunk.length < expanded.length)
})
{
"name": "shrink-string",
"description": "Tiny string compression module",
"version": "1.0.0",
"version": "2.0.0",
"author": {

@@ -6,0 +6,0 @@ "name": "Zac Anger",

@@ -14,7 +14,10 @@ # shrink-string

```javascript
const { encode, decode } = require('shrink-string')
const { compress, decompress } = require('shrink-string')
// `compress` takes a unicode string and returns a base64 string
// `decompress` takes that base64 string and returns the original unicode string
const thing = async (s = '') => {
const shrunk = await encode(s)
const expanded = await decode(shrunk)
const shrunk = await compress(s)
const expanded = await decompress(shrunk)
assert(s === expanded)

@@ -21,0 +24,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc