mirror of
https://github.com/vercel/commerce.git
synced 2025-04-25 12:27:50 +00:00
18 lines
353 B
TypeScript
18 lines
353 B
TypeScript
|
|
import update, { Context } from 'immutability-helper';
|
|
|
|
const c = new Context();
|
|
|
|
c.extend('$auto', function(value, object) {
|
|
return object ?
|
|
c.update(object, value):
|
|
c.update({}, value);
|
|
});
|
|
|
|
c.extend('$autoArray', function(value, object) {
|
|
return object ?
|
|
c.update(object, value):
|
|
c.update([], value);
|
|
});
|
|
|
|
export default c.update |