'use strict';

const _ = require('lodash');

const previous = [];

module.exports = (obj) => {
  const result = obj ? previous.find((item) => _.isEqual(item, obj)) : _.last(previous);

  if (result) {
    return result;
  } else {
    if (obj) {
      previous.push(obj);
    }

    return obj;
  }
};

'use strict';

const _ = require('lodash');

const previous = [];

module.exports = (obj) => {
  let result;

  if (obj != null) {
    result = previous.find((item) => _.isEqual(item, obj));
  }

  if (result) {
    return result;
  } else {
    if (obj != null) {
      previous.push(obj);
    }

    return obj;
  }
};

Remove ability to get last memoize result by passing falsy argument
Remove ability to get last memoize result by passing falsy argument
