Changelog
All notable changes to this project will be documented in this file.
See Conventional Commits for commit guidelines.
7.0.0
💥 BREAKING CHANGES
- Minimum supported Node version is v14.18; we’re dropping v12 support
6.2.0
✨ Features
6.1.2
🔧 Fixed
- tweak types (fd4c820)
6.1.0
✨ Features
- export defaults and version (1107244)
6.0.0
✨ Features
- migrate to ES Modules (8c9d95d)
💥 BREAKING CHANGES
- programs now are in ES Modules and won’t work with Common JS
require()
5.1.0
✨ Features
- config file based major bump blacklisting (e15f9bb)
5.0.15
⏪ Reverts
- Revert “chore: setup refresh” (23cf206)
5.0.1
🔧 Fixed
- add
testStats
to npmignore (f3c84e9)
5.0.0
✨ Features
- rewrite in TS, start using named exports, rebase to be faster (6dbc295)
💥 BREAKING CHANGES
- previously you’d consume:
import flattenReferencing from …
— now:import { flattenReferencing } from …
4.12.0
Accidental version bump during migration to SourceHut. Sorry about that.
4.11.0
✨ Features
- remove check-types-mini options validation to make operation 148 times faster (adbfa37)
4.10.0
- Various documentation and setup tweaks after we migrated to monorepo
- Setup refresh: updated dependencies and all config files using automated tools
4.6.0
- Updated all dependencies
- Restored coveralls.io reporting
- Restored unit test linting
4.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
4.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.
4.3.0
opts.dontWrapKeys
wildcard matching is now key-sensitive. Thanks to matcher release today.
4.2.0
opts.enforceStrictKeyset
. Default istrue
, but if it is set tofalse
, you are allowed to pass in unrecognised keys within an options object. It’s handy when reusing options objects across multiple libraries, where API is similar but not exactly the same. As a drawback, you won’t be alerted if you guess the API wrongly, pass in an option that doesn’t exist in particular library (but you think it does) andcheck-types-mini
(npm, GitLab) detects it and throws an error.
4.1.0
opts.preventWrappingIfContains
. It lets you extend functionality ofopts.wrapHeadsWith
— more variable patterns can be added to be ignored.
4.0.0
New: opts.mergeWithoutTrailingBrIfLineContainsBr
— affects default behaviour
Changed: opts.mergeArraysWithoutLineBreaks
renamed to opts.mergeArraysWithLineBreaks
opts.mergeWithoutTrailingBrIfLineContainsBr
— then we have an array (of strings, for example), but the reference is string we need to flatten that array. Now the default would be separate each line’s content by<br />
. However, sometimes, rows contain conditional content, which is wrapped with IF statements. In those cases, BR is “moved” inside those IF statements, so that when there’s nothing to show, BR is not shown either. This option checks the row’s content for BR’s and if finds any, doesn’t add trailing BR.
[
…
“row1_line”: “\n{%- if %%-row1_var-%% -%}%%_row1_var_%%<br />{%- endif -%}",
“row2_line”: “\n{%- if %%-row2_var-%% -%}%%_row2_var_%%<br />{%- endif -%}",
…
]
Notice how in the example above, <br />
‘s are inside IF conditionals. We wouldn’t want the above flattened to:
\n{%- if %%-row1_var-%% -%}%%_row1_var_%%<br />{%- endif />
\n{%- if %%-row2_var-%% -%}%%_row2_var_%%<br />{%- endif -%}
instead, we want:
\n{%- if %%-row1_var-%% -%}%%_row1_var_%%<br />{%- endif -%}
\n{%- if %%-row2_var-%% -%}%%_row2_var_%%<br />{%- endif -%}
That’s what this feature is about. Also,
opts.mergeArraysWithoutLineBreaks
renamed toopts.mergeArraysWithLineBreaks
. I don’t know what happend in back then in the summer but this setting is named opposite it should have been named.
3.6.0
- 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
. As a bonus, the Babel setup does not ignorenode_modules
where all dependencies sit, what means no matter were they transpiled or not (I’m looking at you, Sindre), this library will not cause problems increate-react-app
and the likes.
3.5.0
opts.dontWrapPaths
— let’s you ignore the paths precisely, for example, you can put an exact path leading to the key like:modules[0].part2[1].ccc[0].kkk
.
3.4.0
- Now serving a transpiled version.
- Raw ESLint, removed JS Standard.
3.3.0
opts.mergeArraysWithoutLineBreaks
to skip adding the<br />
‘s when merging arrays. The problem was that we do need thebr
‘s but when rows are wrapped with conditional statements, thosebr
‘s end up inside the conditional statements, so we need to turn off automatic addition ofbr
‘s because otherwise we would always see them.
Observe this data structure of an imaginary email template, in JSON:
...
“text_field”: [
“%%_row1_line_%%",
“%%_row2_line_%%",
“%%_row3_line_%%”
],
“text_field_data”: {
“row1_line”: “\n{% if %%-row1_var-%% %}%%_row1_var_%%<br />{% endif %}",
“row2_line”: “\n{% if %%-row2_var-%% %}%%_row2_var_%%<br />{% endif %}",
“row3_line”: “\n{% if %%-row3_var-%% %}%%_row3_var_%%<br />{% endif %}",
“row1_var”: “addressLine1″,
“row2_var”: “addressLine2″,
“row3_var”: “addressLine3″
},
…
With opts.mergeArraysWithoutLineBreaks
off, the flatten function of this library would add line breaks to after %%_row1_line_%%
and %%_row2_line_%%
, but that’s wrong, because they would end up outside of conditional statements. Actually, those br
‘s would even be redundant anyway, notice how row1_line
, row2_line
and row3_line
already have br
‘s inside conditional Nunjucks statements…
3.2.0
- More improvements to the array-within-array flattening scenarios.
3.1.0
- When deeper level array is flattened referencing a string, result is the sum of all strings within the array, joined with a space, and each string wrapped according to wrapping settings.
For example, [‘aaa’, ‘bbb’, ‘ccc’]
referencing string ‘zzz’ would yield string %%_aaa_%% %%_bbb_%% %%_ccc_%%
(that’s default wrapping settings, which can be customised).
3.0.0
- 🔧
opts.wrapHeads
is nowopts.wrapHeadsWith
- 🔧
opts.wrapTails
is nowopts.wrapTailsWith
2.0.0
- 🔧 Major API change and major semver bump:
opts.dontWrapKeysStartingWith
andopts.dontWrapKeysEndingWith
are now one key,opts.dontWrapKeys
and the same (and better) result is achieved using wildcards (*
symbols). Now you can have as many wildcards as you like, not only at the beginning or the ending of a string (or arrays of strings), but also anywhere in the middle too. Also you can set multiple wildcards in the same string.
1.2.0
- Made the algorithm to be even more smarter: when the value has no spaces around already existing
heads
andtails
, for example{{value}}
, but you want, in general, to have a space around your wrappings, you setheads
for for example:{{
with a trailing space. Previously, this would have caused double wrapping. Now,heads
andtails
are trimmed before search, so go crazy with the white space!
1.1.0
- New options setting
opts.ignore
which lets you skip flattening on an array (or a single string) of keys. - New options setting
opts.whatToDoWhenReferenceIsMissing
which allows you to specify exactly what do you want to happen when the equivalent value in the reference (object/array/string/whatever) is falsey. - 🔧 Done some rebasing, for example,
util.arrayiffyString
now DRY’ies the code a bit.
1.0.0
- First public release