0.0.2 • Published 7 years ago
destring v0.0.2
destring
Configurable strings cache swaps between strings and their ID.
This package:
- knows strings to replace instead of sending the whole string
- can be pre-configured with strings
- can learn strings during communications
- can limit the number of strings in its cache
- can limit the bytes of strings stored in its cache
See packages:
NOTE: placeholder
Install
npm install destring --save
Usage
// get the builder
var buildDestring = require('destring')
// build one we can train
, destring = buildDestring({
// by default, there are no limits
limit: 101, // limit by *number* of strings
bytes: 10 * 1024,// limit by bytes of strings
minLength: 4, // min chars in string to learn it
maxLength: 100, // avoid "learning" very long strings
// which strings should it know already.
// by default, it knows none.
strings: [
'key1', 'some value'
]
})
// get `which` string this is in the cache, its ID
, which = destring.string('key1')
// get the original string based on the `which` (ID)
, string = destring.id(which)
// can teach it some strings to replace at any time.
destring.add(strings)