Skip to content

Commit

Permalink
Merge efc8081 into 954b348
Browse files Browse the repository at this point in the history
  • Loading branch information
compulim committed May 26, 2020
2 parents 954b348 + efc8081 commit db6dceb
Show file tree
Hide file tree
Showing 7 changed files with 3,973 additions and 2,896 deletions.
10 changes: 10 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
arrowParens: avoid
bracketSpacing: true
jsxBracketSameLine: false
printWidth: 120
proseWrap: preserve
quoteProps: as-needed
semi: true
singleQuote: true
tabWidth: 2
trailingComma: none
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,38 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Bump dependencies, in PR [#29](https://github.com/compulim/simple-update-in/pulls/29)
- [`@babel/cli@7.8.4`](https://npmjs.com/package/@babel/cli)
- [`@babel/core@7.9.6`](https://npmjs.com/package/@babel/core)
- [`@babel/plugin-proposal-object-rest-spread@7.9.6`](https://npmjs.com/package/@babel/plugin-proposal-object-rest-spread)
- [`@babel/preset-env@7.9.6`](https://npmjs.com/package/@babel/preset-env)
- [`babel-jest@26.0.1`](https://npmjs.com/package/babel-jest)
- [`coveralls@3.1.0`](https://npmjs.com/package/coveralls)
- [`jest@26.0.1`](https://npmjs.com/package/jest)
- [`regenerator-runtime@0.13.5`](https://npmjs.com/package/regenerator-runtime)
- [`rollup@2.10.9`](https://npmjs.com/package/rollup)
- [`rollup-plugin-babel@4.4.0`](https://npmjs.com/package/rollup-plugin-babel)
- [`rollup-plugin-uglify@6.0.4`](https://npmjs.com/package/rollup-plugin-uglify)

## [2.1.1] - 2019-08-01

### Changed

- Fix [#24](https://github.com/compulim/simple-update-in/issues/24), polyfill `Object.is` for IE11, in PR [#25](https://github.com/compulim/simple-update-in/pull/25)
- Polyfill code is adopted from [`core-js`](https://npmjs.com/package/core-js) to maintain zero dependency

## [2.1.0] - 2019-07-18

### Changed

- Bump dependencies, in PR [#18](https://github.com/compulim/simple-update-in/pulls/18)
- [`@babel/cli@^7.5.5`](https://www.npmjs.com/package/@babel/cli)
- [`@babel/core@^7.5.5`](https://www.npmjs.com/package/@babel/core)
Expand All @@ -30,71 +50,95 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `Object.is` correctly compare between `0` and `-0` (different), and `NaN` and `Number.NaN` (indifferent)

### Added

- Will skip paths containing `__proto__`, `constructor`, and `prototype`, in PR [#19](https://github.com/compulim/simple-update-in/pull/19)

## [2.0.2] - 2018-12-06

### Fixed

- Fix [#16](https://github.com/compulim/simple-update-in/issues/16), parents should not be removed when `updater` is or returned `undefined`, in PR [#17](https://github.com/compulim/simple-update-in/pull/17)

## [2.0.1] - 2018-12-03

### Added

- Emitting UMD bundle for browser
- `<script src="https://unpkg.com/simple-update-in/dist/simple-update-in.production.min.js"></script>`
- `<script>window.simpleUpdateIn({ abc: 123, def: 456 }, ['xyz'], () => 789);</script>`

## [2.0.0] - 2018-12-03

### Added

- Support async predicate
- `await updateIn([1, 2, 3, 4, 5], [v => Promise.resolve(v % 2)], v => v * 10)` will return `[10, 2, 30, 4, 50]`
- Support async update
- `await updateIn([1, 2, 3], [0], v => Promise.resolve(v * 10))` will return `[10, 2, 3]`

### Changed

- Use Node.js 10 and 11 for Travis CI

### Removed

- Removed array insertion using index number of `-1`
- This introduces API inconfirmity: `-1` could means append, prepend, or the last item

## [1.4.0] - 2018-10-08

### Changed

- Add default exports for CommonJS
- Bump
- `@babel/core@7.1.2`
- `merge@1.2.1` (via `npm audit fix`)
- `jest@23.6.0`

## [1.3.1] - 2018-10-05

### Fixed

- Using a predicate on a non-existing key/index should not throw error and return the original value as-is
- `updateIn({}, ['Hello', () => true], () => 'World!'])` will return `{}`
- `updateIn([], [0, () => true], () => 'Aloha'])` will return `[]`

## [1.3.0] - 2018-08-17

### Added

- Support predicate function
- `updateIn([1, 2, 3, 4, 5], [v => v % 2], v => v * 10)` will return `[10, 2, 30, 4, 50]`
- Predicate function can be used as branching function to update multiple subtrees in a single call

## [1.2.0] - 2018-04-14

### Added

- If after `updater` result in nothing change (triple-equal `===`), will return untouched
- `updater` returned `undefined` will be treated as removing the item

### Fixed

- Append not creating sub-structure correctly
- `updateIn([1, 2], [-1, 0], 'Hello')` should return `[1, 2, ['Hello']]` instead of `[1, 2, 'Hello']`

## [1.1.1] - 2018-04-06

### Fixed

- Move `babel` and `gulp` into `devDependencies`

## [1.1.0] - 2018-03-31

### Added

- Automatic expansion
- Replace incompatible types
- Array insertion using index number of `-1`

## [1.0.0] - 2018-03-21

### Added

- Initial commit
8 changes: 8 additions & 0 deletions __tests__/dist.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="../dist/simple-update-in.production.min.js"></script>
</head>
<body>
</body>
</html>
24 changes: 24 additions & 0 deletions __tests__/dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* @jest-environment jsdom
*/

import 'regenerator-runtime';
import { join } from 'path';
import { JSDOM } from 'jsdom';

async function waitOnce(eventTarget, name) {
return new Promise(resolve => eventTarget.addEventListener(name, resolve, { once: true }));
}

test('Able to load via window.simpleUpdateIn', async () => {
const { window } = await JSDOM.fromFile(join(__dirname, 'dist.html'), {
resources: 'usable',
runScripts: 'dangerously'
});

await waitOnce(window, 'load');

const actual = window.simpleUpdateIn({ one: 1, two: 2 }, ['three'], () => 3);

expect(actual).toEqual({ one: 1, two: 2, three: 3 });
});
4 changes: 4 additions & 0 deletions jest.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"collectCoverage": true,
"testEnvironment": "node"
}
Loading

0 comments on commit db6dceb

Please sign in to comment.