npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aspiesoft/cwsclib

v1.0.2

Published

A compression library for strings, that recognizes common words, and creates references to them.

Downloads

5

Readme

Common Word String Compression Library

npm version GitHub top language GitHub license

npm downloads npm downloads jsDelivr hits (GitHub)

paypal

A compression library for strings, that recognizes common words, and creates references to them

A compression library for strings, that recognizes common words, and creates references to them. Because these word references are built within the cdn, they should get cached and reduce the amount of data sent to the client.

This algorithm checks if the string got smaller or larger at each step, and does Not add methods that become larger than the original result from the last method. The algorithm attempts to reduce repeating words, and generate utf8 character based references to allow fast decompression.

Usually decompression is faster than compression, as compression should make the string as small as possible, and decompression is usually when you actually need the string.

Installation

node.js


npm install @aspiesoft/cwsclib

# or with no optional dependencies
npm install @aspiesoft/cwsclib --no-optional

cdn


<!-- Optional: add secondary compression (will detect automatically) -->
<script src="https://cdn.jsdelivr.net/gh/nodeca/[email protected]/dist/pako.min.js" charset="utf-8"></script>


<!-- Note: charset="utf-8" is necessary for the script to use utf-8 character references properly -->
<script src="https://cdn.jsdelivr.net/gh/AspieSoft/cwscLib@1/script.min.js" charset="utf-8"></script>

Usage


// require only if using node.js
const cwscLib = require('@aspiesoft/cwsclib');

let str = 'the cdn.jsdelivr.net javascript engine built in year 2020 by aspiesoft';

let compressed = cwscLib.compress(str, 9).toString(); // output: §1:0><qU> <&> <*b> <NŒ> <Xx> in <l‰> 2020 by <-2>

let decompressed = cwscLib.decompress(compressed); // output: the cdn.jsdelivr.net javascript engine built in year 2020 by aspiesoft

// note: the compressed string may appear different, if you add an optional compression after this compression (depending on if it gets smaller)


let speed = 1; // any number between 0 and 9
/*
  speed = 1 (fastest)
  speed = 9 (best) (default)
*/

let compression = cwscLib.compress(str, speed);
/*
  output: {
    comp: '0><qU> <&> <*b> <NŒ> <Xx> in <l‰> 2020 by <-2>',
    ver: 1,
    compType: 0,
    toString: [Function: toString],
    toJSON: [Function: toJSON],
    decomp: [Function: decomp]
  }
*/

compression.toJSON(); // output: compression object without functions (useful for storing json)

compression.decomp(); // output: original string
cwscLib.decompress(compression); // output: original string
cwscLib.decompress(compression.toJSON()); // output: original string


cwscLib.compress('11111 222 33 4444444 5555555555 6 7 888888888888 999999999999').toString(); // output: §1:1>2:1 0:2 33 4:4 7:5 6 7 9:8 9:9