Comparing version 0.4.1 to 0.4.2
# Changelog | ||
### 0.4.2 | ||
* Fixed generating a wrong property descriptor for the `length` property of arrays. Fixes [#50](https://github.com/mweststrate/immer/issues/50) | ||
* Defining custom properties on drafts is no longer supported | ||
### 0.4.1 | ||
@@ -4,0 +9,0 @@ |
@@ -157,3 +157,4 @@ "use strict" | ||
const descriptor = Reflect.getOwnPropertyDescriptor(owner, prop) | ||
if (descriptor) descriptor.configurable = true // XXX: is this really needed? | ||
if (descriptor && !(Array.isArray(owner) && prop === "length")) | ||
descriptor.configurable = true | ||
return descriptor | ||
@@ -163,4 +164,5 @@ } | ||
defineProperty(property, descriptor) { | ||
this.markChanged() | ||
Object.defineProperty(this.copy, property, descriptor) | ||
throw new Error( | ||
"Immer does currently not support defining properties on draft objects" | ||
) | ||
} | ||
@@ -167,0 +169,0 @@ |
@@ -158,3 +158,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.immer = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
const descriptor = Reflect.getOwnPropertyDescriptor(owner, prop) | ||
if (descriptor) descriptor.configurable = true // XXX: is this really needed? | ||
if (descriptor && !(Array.isArray(owner) && prop === "length")) | ||
descriptor.configurable = true | ||
return descriptor | ||
@@ -164,4 +165,5 @@ } | ||
defineProperty(property, descriptor) { | ||
this.markChanged() | ||
Object.defineProperty(this.copy, property, descriptor) | ||
throw new Error( | ||
"Immer does currently not support defining properties on draft objects" | ||
) | ||
} | ||
@@ -168,0 +170,0 @@ |
{ | ||
"name": "immer", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"description": "Create your next immutable state by mutating the current one", | ||
@@ -5,0 +5,0 @@ "main": "immer.js", |
@@ -126,8 +126,10 @@ # Immer | ||
Note that it is not needed to handle the default case, a producer that doesn't do anything will simply return the original state. | ||
Notice that it is not needed to handle the default case, a producer that doesn't do anything will simply return the original state. | ||
_Note, creating Redux reducer is just a sample application of the Immer package. | ||
Creating Redux reducer is just a sample application of the Immer package. | ||
Immer is not just designed to simplify Redux reducers. | ||
It can be used in any context where you have an immutable data tree that you want to clone and modify (with structural sharing)_ | ||
It can be used in any context where you have an immutable data tree that you want to clone and modify (with structural sharing). | ||
_Note: it might be tempting after using producers a while, to just put `produce` in your root reducer, and then past the draft along to each reducer and work on that. Don't do that. It kills the point of Redux where each reducer is testable as pure reducer. Immer is best used when applying it to small individual pieces of logic._ | ||
## Currying | ||
@@ -155,2 +157,4 @@ | ||
```javascript | ||
import produce from 'immer' | ||
const byId = produce((draft, action) => { | ||
@@ -157,0 +161,0 @@ switch (action.type) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57577
1048
291