shrink-string
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -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 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5557
29