Changelog
All notable changes to this project will be documented in this file.
See Conventional Commits for commit guidelines.
11.0.0
💥 BREAKING CHANGES
- Minimum supported Node version is v14.18; we’re dropping v12 support
10.2.0
✨ Features
10.1.0
✨ Features
- export defaults and version (1107244)
10.0.0
✨ Features
- migrate to ES Modules (8c9d95d)
💥 BREAKING CHANGES
- programs now are in ES Modules and won’t work with Common JS
require()
9.1.0
✨ Features
- config file based major bump blacklisting (e15f9bb)
9.0.15
⏪ Reverts
- Revert “chore: setup refresh” (23cf206)
9.0.1
🔧 Fixed
- add
testStats
to npmignore (f3c84e9)
9.0.0
✨ Features
- rewrite in TS, start using named exports (70f7388)
💥 BREAKING CHANGES
- previously you’d consume like:
import collapse from …
— now:import { collapse } from …
7.0.0
A major rewrite.
- complete rewrite (0040bc5)
Each whitespace chunk is needed is passed through a callback (even when there is no action needed). This allows you to granularly control the collapsing. For example, you can delete the single spaces between two characters under certain circumstances (a thing not available by existing options’ settings) — for example, minify css selectors:
div > span {
color: red;
}
Imagine you are minifying the code above and parser extracted the div > span
part. Now you want to collapse excessive whitespace like div \t > \t span
(spaces with tabs), but also remove even single spaces, to turn it into div>span
.
Easy!
import { strict as assert } from “assert”;
import collapse from “../dist/string-collapse-white-space.esm.js”;
assert.equal(
collapse(`div > span`, {
cb: ({ suggested, whiteSpaceStartsAt, whiteSpaceEndsAt, str }) => {
if (str[whiteSpaceStartsAt — 1] === “>") {
return [whiteSpaceStartsAt, whiteSpaceEndsAt];
}
if (str[whiteSpaceEndsAt] === “>") {
return [whiteSpaceStartsAt, whiteSpaceEndsAt];
}
return suggested;
},
}).result,
“div>span”
);
✨ Features
opts.cb
💥 BREAKING CHANGES
- removed
opts.recogniseHTML
- removed
opts.rangesOffset
(useranges-offset
)
Also, properly tested and fixed opts.enforceSpacesOnly
. It now works as intended, considering all edge cases and interaction with other options.
6.1.0
✨ Features
opts.enforceSpacesOnly
(154de62)
6.0.0
✨ Features
- returns a plain object with both string and ranges (275b940)
💥 BREAKING CHANGES
- returns a plain object with both string and ranges
5.2.0
✨ Features
- proper support for all possible kinds of line end symbols (5a49049)
5.2.0
- full support for all kinds of linebreaks: LF, CR or CRLF
- basic unit tests for UMD and CJS builds, to check their integrity (rather than functionality, which is covered properly by ES Modules build tests)
5.1.2
🔧 Fixed
- string boundary won’t throw now, sorry about that (94639dd)
5.1.0
✨ Features
opts.limitConsecutiveEmptyLinesTo
(ece9334)
4.5.0
- Various documentation and setup tweaks after we migrated to monorepo
- Setup refresh: updated dependencies and all config files using automated tools
4.3.0
- Add dynamically generated tests — 10000 random strings are checked to catch any false-positives (43d7dc4)
- Add
opts.removeEmptyLines
(75e0671)
4.2.0
- Updated all dependencies
- Restored coveralls.io reporting
- Restored unit test linting
4.1.0
- Fixed a strange false-positive bug which was happening around the encountered first bracket when there was no whitespace to remove, but with only a single line break. Sorry about that.
- To iron-out all false-positive cases, I created an 8th group unit test where
10,000
randomly generated strings that don’t contain anything to collapse are checked. Various pieces are assembled in random order and length:<br>
,<br/>
,<zzz class=“yyy”>
,zzz
,1
,_
,a
,&
,#
,.
. Plus, there are single spaces in-between, added with 25% probability.
Here are ten examples of randomly-generated text which should not be changed by string-collapse function (notice there are maximum one space everywhere):
& 1 _<br/>#<br/><br><br> <br>_a1
a&1_.zzz<br/>.#zzz<br>&.<zzz class=“yyy”> <zzz class=“yyy”>a zzz<br/>_<br><br/> <zzz class=“yyy”><br/><zzz class=“yyy”>zzz1<br>_ <br><br><br>_# <zzz class=“yyy”>_.<br/>a1zzz 1.zzz<br/><zzz class=“yyy”>&<zzz class=“yyy”>.<br>.
aaa1<br>1a &a1<br/>1<br/> <br>..#_1zzz _<br><br/> <zzz class=“yyy”>1 <br/>zzz azzz&<br>a& &<br/> _a &<zzz class=“yyy”>#
<zzz class=“yyy”>__aa..#
_<zzz class=“yyy”> <br>. _<br/>zzz… <br/>zzz<br/> 1.<br/> & zzz& 1zzza <br> <br/> <br><br><br>&<zzz class=“yyy”>zzz1.zzz._& _ ##<br>a#<br>.<br/>
.a<br>zzz _& 1_ 1zzz<zzz class=“yyy”> <br/>#<br/>zzz & #<br/><br/> &<br>&<zzz class=“yyy”>_<br/><zzz class=“yyy”>.&a<br> &_#_
_azzz 11##
a.<br/>.<br/><br><br/><br/><br/><br/> # _1 1<zzz class=“yyy”> .<br/>1<br>&# <br/><br/> <br>_aa <br/>
## zzz& .# .a&1&_aa 1 zzz<zzz class=“yyy”>zzz.zzz_zzz_##_## <br><br/><br/>1
<zzz class=“yyy”> zzz 1<zzz class=“yyy”>_1<br>zzz.&<zzz class=“yyy”> #___zzz<zzz class=“yyy”>.a a_<br/>1_. <br/> <br/><br> . _1 <br/>
Hopefully bugs like the one we just fixed should not happen any more 🤞
4.0.0
- When
opts.returnRangesOnly
is on and there are no results, instead ofnull
(a falsey thing) now we return empty array (a truthy thing). It’s better now because while you can’t easily check for its existence (a laif result
), actually you don’t have to any more. Just map over its result. It will always be array, albeit sometimes empty.
3.7.0
- Set up Rollup to remove comments from the code
3.6.0
- Two
range-
dependencies have been renamed, namely ranges-push and ranges-apply. We tapped them.
3.5.0
GitHub sold us out. In the meantime, we:
- Migrated to BitBucket (to host repo + perform CI) and Codacy (for code quality audit)
- Dropped BitHound (RIP) and Travis
- Removed
package-lock
- Added new feature —
opts.returnRangesOnly
3.4.0
- Set up Prettier on a custom ESLint rule set.
- Removed
package.lock
and.editorconfig
- Wired Rollup to remove comments from non-dev builds. This means we can now leave the
console.log
s in the source code — there’s no need to comment-outconsole.log
statements or care about them not spilling into production. Now it’s done automatically. - Unit tests are pointing at ES modules build, which means that code coverage is correct now, without Babel functions being missed. This is important because now code coverage is real again and now there are no excuses not to perfect it.
3.3.0
✨ Features
opts.removeEmptyLines
- Set up Prettier to run automatically on all relevant files. Dropping
airbnb-base
ESLint preset. - Stopping to commit (and generate at all)
package-lock
files - Beefed up unit tests, filled all missing rows. Obviously, unit tests will be ran against the transpiled code (as well as nyc/coveralls reporting) and I can’t unit-test some of the functions that Babel adds. Hence not perfect coverage score.
3.2.0
✨ Features
- Removed the look left-right matching function into a separate library, string-match-left-right and tapped it. Also did some tiny code rebasing.
3.1.0
✨ Features
- AVA unit test linting via ESLint plugin
3.0.0
✨ Features
- The main source now is in ES2015 modules with
import
/export
. - Implemented Rollup to generate 3 flavours of this package: CommonJS, UMD and ESM
module
withimport
/export
. opts.recogniseHTML
(default true) — if string contains HTML, whitespace around brackets will be collapsed completely, for example:< img
=><img
, not< img
=>< img
as before. The “before” result now would yield only with this new setting turned off. Total 118 opening HTML tags are recognised (with or without attributes).
2.2.0
✨ Features
opts.trimLines
— activates trim per-line basisopts.trimnbsp
— non-breaking spaces are trimmed too- switched to ESLint on
airbnb-base
config, with 3 exceptions: 1. no semicolons; 2. plus-plus allowed in loops;
2.1.0
✨ Features
- Correctly treats non-breaking spaces — they are not considered collapsable or trimmable now.
2.0.0
✈️ Changes
- This morning I didn’t like yesterday’s v.1 API at all, personally I think it was stupid. So, I simplified it and basically, recoded the whole thing.
1.0.0
- First public release