Skip to content

Commit

Permalink
Merge pull request #132 from calmm-js/feature/drop-removal-of-empty-t…
Browse files Browse the repository at this point in the history
…hings-by-default

Drop dy default removal of empty arrays, objects, and strings
  • Loading branch information
polytypic authored Oct 14, 2017
2 parents f7ad397 + dcb60dd commit 0b5d87e
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 277 deletions.
24 changes: 20 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,28 @@
# Changelog
# Partial Lenses Changelog

## 12.0.0
## 13.0.0

As discussed in issue
[#131](https://github.com/calmm-js/partial.lenses/issues/131), optics working on
arrays, objects, and strings, no longer remove empty values by default. It
appears that by default removal, on average, makes optics compositions more
complex. In most cases this change means that uses of `L.define` or
`L.required` with an empty value `{}`, `[]`, or `""`, can simply be removed.
`L.define` and `L.required` now give a warning in case they are used with an
empty value and a matching empty value passes through them redundantly. In
cases where removal of empty values is desired, one can e.g. compose with
`L.defaults`.

Removed previously obsoleted `L.findHint`.

The current plan is to change Partial Lenses to support so called naked or
prototypeless objects with `null` prototype (i.e. `Object.create(null)`) in the
next major version. This is a breaking change although it is likely that it
will not affect most users. Usefully warning for this change of behaviour by
adding diagnostics to optics seems somewhat difficult.
adding diagnostics to optics seems somewhat difficult. *This note was moved
from 12.0.0.*

## 12.0.0

As documented in 11.21.0:
* Support for lazy algebras with the `delay` function was removed.
Expand Down Expand Up @@ -114,7 +130,7 @@ bug fix as the behaviour wasn't previously strictly specified.
## 10.0.0

As discussed in issue
[50](https://github.com/calmm-js/partial.lenses/issues/50), to strongly guide
[#50](https://github.com/calmm-js/partial.lenses/issues/50), to strongly guide
away from mutating data structures, optics now
[`Object.freeze`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze)
any new objects they create when `NODE_ENV` is not `production`. Note that
Expand Down
6 changes: 1 addition & 5 deletions EXERCISES.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ test('rem', L.remove(lens, nested), undefined)
search for an object with the given key.</span>
* Support removal.
* <span class="hint">Use [`L.removable`](/#L-valueOr).</span>
* Make it so that the array does not become `undefined` once empty.
* <span class="hint">Use [`L.define`](/#L-define).</span>
* Support insertion and make it so that keys remain ordered.
* <span class="hint">Use [`L.valueOr`](/#L-valueOr) to add the `key`
property in case there is no matching object.</span>
Expand Down Expand Up @@ -148,10 +146,8 @@ test('set_ext', L.set(end, 4, {start: 1, num: 2, xtra: 'field'}), {start: 1, num
* Define a traversal that targets the `x` properties of the coordinate pairs.
* <span class="hint">Compose [`L.elems`](/#L-elems) and
[`'x'`](/#L-prop).</span>
* Support removal so that the whole coordinate pair is removed and removing the
last one produces an empty array.
* Support removal so that the whole coordinate pair is removed.
* <span class="hint">Use [`L.removable`](/#L-removable).</span>
* <span class="hint">Use [`L.define`](/#L-define).</span>

```js
const xs = '???'
Expand Down
Loading

0 comments on commit 0b5d87e

Please sign in to comment.