Skip to content

Commit

Permalink
Revert "Merge pull request #34 from substantial/default-to-array"
Browse files Browse the repository at this point in the history
This reverts commit 12bf952, reversing
changes made to 7a35404.
  • Loading branch information
aaronjensen committed Nov 16, 2015
1 parent 43d34e0 commit 485bde7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 61 deletions.
10 changes: 7 additions & 3 deletions lib/update.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import wrap from './wrap';
import isEmpty from './util/isEmpty';
import defaultObject from './util/defaultObject';
import isPlainObject from 'lodash/lang/isPlainObject';

function isEmpty(object) {
return !Object.keys(object).length;
}

function reduce(object, callback, initialValue) {
return Object.keys(object).reduce((acc, key) => {
return callback(acc, object[key], key);
Expand Down Expand Up @@ -63,7 +65,9 @@ function update(updates, object, ...args) {
return updates;
}

const defaultedObject = defaultObject(object, updates);
const defaultedObject = (typeof object === 'undefined' || object === null) ?
{} :
object;

const resolvedUpdates = resolveUpdates(updates, defaultedObject);

Expand Down
35 changes: 0 additions & 35 deletions lib/util/defaultObject.js

This file was deleted.

5 changes: 0 additions & 5 deletions lib/util/isEmpty.js

This file was deleted.

6 changes: 0 additions & 6 deletions test/updateIn-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ describe('u.updateIn', () => {
expect(result).to.eql({ a: [0, 3, 0] });
});

it('can create array if all keys are numbers', () => {
const result = u.updateIn('a.0', 3, null);

expect(result).to.eql({ a: [3] });
});

it('can be partially applied', () => {
const object = { a: { b: 0 } };
const result = u.updateIn('a.b')(3)(object);
Expand Down
12 changes: 0 additions & 12 deletions test/updeep-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,6 @@ describe('updeep', () => {
expect(u(null, {})).to.be.null;
});

it('can create array if all keys are numbers', () => {
const result = u({ 0: 'hi', '1': 'world' }, null);

expect(result).to.eql(['hi', 'world']);
});

it('does not create array if any key is not number', () => {
const result = u({ 0: 'hi', '1a': 'world' }, null);

expect(result).to.eql({ 0: 'hi', '1a': 'world' });
});

it('can add an element to an array', () => {
const object = [];
const result = u({ 0: 3 }, object);
Expand Down

0 comments on commit 485bde7

Please sign in to comment.