Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

timm

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timm - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

4

CHANGELOG.md
# Changelog
## 1.2.2 (December 7, 2016)
* Bugfix: Allow `setIn` to automatically create arrays [#3, @YellowKirby]
## 1.2.1 (November 15, 2016)

@@ -4,0 +8,0 @@

3

lib/timm.js

@@ -309,3 +309,4 @@ 'use strict';

function set(obj, key, val) {
var finalObj = obj == null ? {} : obj;
var fallback = Number.isInteger(key) ? [] : {};
var finalObj = obj == null ? fallback : obj;
if (finalObj[key] === val) return finalObj;

@@ -312,0 +313,0 @@ var obj2 = clone(finalObj);

@@ -1,2 +0,2 @@

"use strict";function throwStr(e){throw new Error(e)}function clone(e){if(Array.isArray(e))return e.slice();for(var r=Object.keys(e),t={},n=0;n<r.length;n++){var o=r[n];t[o]=e[o]}return t}function doMerge(e,r){var t=r;!(null!=t)&&throwStr(INVALID_ARGS);for(var n=!1,o=arguments.length,a=Array(o>2?o-2:0),s=2;o>s;s++)a[s-2]=arguments[s];for(var l=0;l<a.length;l++){var i=a[l];if(null!=i){var u=Object.keys(i);if(u.length)for(var c=0;c<=u.length;c++){var d=u[c];if(!e||void 0===t[d]){var f=i[d];void 0!==f&&f!==t[d]&&(n||(n=!0,t=clone(t)),t[d]=f)}}}}return t}function isObject(e){var r="undefined"==typeof e?"undefined":_typeof(e);return null!=e&&("object"===r||"function"===r)}function addLast(e,r){return e.concat(Array.isArray(r)?r:[r])}function addFirst(e,r){return Array.isArray(r)?r.concat(e):[r].concat(e)}function removeLast(e){return e.length?e.slice(0,e.length-1):e}function removeFirst(e){return e.length?e.slice(1):e}function insert(e,r,t){return e.slice(0,r).concat(Array.isArray(t)?t:[t]).concat(e.slice(r))}function removeAt(e,r){return r>=e.length||0>r?e:e.slice(0,r).concat(e.slice(r+1))}function replaceAt(e,r,t){return e[r]===t?e:e.slice(0,r).concat([t]).concat(e.slice(r+1))}function getIn(e,r){if(!Array.isArray(r)&&throwStr(INVALID_ARGS),null==e)return void 0;for(var t=e,n=0;n<r.length;n++){var o=r[n];if(t=null!=t?t[o]:void 0,void 0===t)return t}return t}function set(e,r,t){var n=null==e?{}:e;if(n[r]===t)return n;var o=clone(n);return o[r]=t,o}function doSetIn(e,r,t,n){var o=void 0,a=r[n];if(n===r.length-1)o=t;else{var s=isObject(e)?e[a]:{};o=doSetIn(s,r,t,n+1)}return set(e,a,o)}function setIn(e,r,t){return r.length?doSetIn(e,r,t,0):t}function updateIn(e,r,t){var n=getIn(e,r),o=t(n);return setIn(e,r,o)}function merge(e,r,t,n,o,a){for(var s=arguments.length,l=Array(s>6?s-6:0),i=6;s>i;i++)l[i-6]=arguments[i];return l.length?doMerge.call.apply(doMerge,[null,!1,e,r,t,n,o,a].concat(l)):doMerge(!1,e,r,t,n,o,a)}function mergeIn(e,r,t,n,o,a,s){var l=getIn(e,r);null==l&&(l={});for(var i=void 0,u=arguments.length,c=Array(u>7?u-7:0),d=7;u>d;d++)c[d-7]=arguments[d];return i=c.length?doMerge.call.apply(doMerge,[null,!1,l,t,n,o,a,s].concat(c)):doMerge(!1,l,t,n,o,a,s),setIn(e,r,i)}function omit(e,r){for(var t=Array.isArray(r)?r:[r],n=!1,o=0;o<t.length;o++)if(hasOwnProperty.call(e,t[o])){n=!0;break}if(!n)return e;for(var a={},s=Object.keys(e),l=0;l<s.length;l++){var i=s[l];t.indexOf(i)>=0||(a[i]=e[i])}return a}function addDefaults(e,r,t,n,o,a){for(var s=arguments.length,l=Array(s>6?s-6:0),i=6;s>i;i++)l[i-6]=arguments[i];return l.length?doMerge.call.apply(doMerge,[null,!0,e,r,t,n,o,a].concat(l)):doMerge(!0,e,r,t,n,o,a)}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};exports.clone=clone,exports.addLast=addLast,exports.addFirst=addFirst,exports.removeLast=removeLast,exports.removeFirst=removeFirst,exports.insert=insert,exports.removeAt=removeAt,exports.replaceAt=replaceAt,exports.getIn=getIn,exports.set=set,exports.setIn=setIn,exports.updateIn=updateIn,exports.merge=merge,exports.mergeIn=mergeIn,exports.omit=omit,exports.addDefaults=addDefaults;/*!
"use strict";function throwStr(e){throw new Error(e)}function clone(e){if(Array.isArray(e))return e.slice();for(var r=Object.keys(e),t={},n=0;n<r.length;n++){var o=r[n];t[o]=e[o]}return t}function doMerge(e,r){var t=r;!(null!=t)&&throwStr(INVALID_ARGS);for(var n=!1,o=arguments.length,a=Array(o>2?o-2:0),s=2;o>s;s++)a[s-2]=arguments[s];for(var i=0;i<a.length;i++){var l=a[i];if(null!=l){var u=Object.keys(l);if(u.length)for(var c=0;c<=u.length;c++){var d=u[c];if(!e||void 0===t[d]){var f=l[d];void 0!==f&&f!==t[d]&&(n||(n=!0,t=clone(t)),t[d]=f)}}}}return t}function isObject(e){var r="undefined"==typeof e?"undefined":_typeof(e);return null!=e&&("object"===r||"function"===r)}function addLast(e,r){return e.concat(Array.isArray(r)?r:[r])}function addFirst(e,r){return Array.isArray(r)?r.concat(e):[r].concat(e)}function removeLast(e){return e.length?e.slice(0,e.length-1):e}function removeFirst(e){return e.length?e.slice(1):e}function insert(e,r,t){return e.slice(0,r).concat(Array.isArray(t)?t:[t]).concat(e.slice(r))}function removeAt(e,r){return r>=e.length||0>r?e:e.slice(0,r).concat(e.slice(r+1))}function replaceAt(e,r,t){return e[r]===t?e:e.slice(0,r).concat([t]).concat(e.slice(r+1))}function getIn(e,r){if(!Array.isArray(r)&&throwStr(INVALID_ARGS),null==e)return void 0;for(var t=e,n=0;n<r.length;n++){var o=r[n];if(t=null!=t?t[o]:void 0,void 0===t)return t}return t}function set(e,r,t){var n=Number.isInteger(r)?[]:{},o=null==e?n:e;if(o[r]===t)return o;var a=clone(o);return a[r]=t,a}function doSetIn(e,r,t,n){var o=void 0,a=r[n];if(n===r.length-1)o=t;else{var s=isObject(e)?e[a]:{};o=doSetIn(s,r,t,n+1)}return set(e,a,o)}function setIn(e,r,t){return r.length?doSetIn(e,r,t,0):t}function updateIn(e,r,t){var n=getIn(e,r),o=t(n);return setIn(e,r,o)}function merge(e,r,t,n,o,a){for(var s=arguments.length,i=Array(s>6?s-6:0),l=6;s>l;l++)i[l-6]=arguments[l];return i.length?doMerge.call.apply(doMerge,[null,!1,e,r,t,n,o,a].concat(i)):doMerge(!1,e,r,t,n,o,a)}function mergeIn(e,r,t,n,o,a,s){var i=getIn(e,r);null==i&&(i={});for(var l=void 0,u=arguments.length,c=Array(u>7?u-7:0),d=7;u>d;d++)c[d-7]=arguments[d];return l=c.length?doMerge.call.apply(doMerge,[null,!1,i,t,n,o,a,s].concat(c)):doMerge(!1,i,t,n,o,a,s),setIn(e,r,l)}function omit(e,r){for(var t=Array.isArray(r)?r:[r],n=!1,o=0;o<t.length;o++)if(hasOwnProperty.call(e,t[o])){n=!0;break}if(!n)return e;for(var a={},s=Object.keys(e),i=0;i<s.length;i++){var l=s[i];t.indexOf(l)>=0||(a[l]=e[l])}return a}function addDefaults(e,r,t,n,o,a){for(var s=arguments.length,i=Array(s>6?s-6:0),l=6;s>l;l++)i[l-6]=arguments[l];return i.length?doMerge.call.apply(doMerge,[null,!0,e,r,t,n,o,a].concat(i)):doMerge(!0,e,r,t,n,o,a)}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};exports.clone=clone,exports.addLast=addLast,exports.addFirst=addFirst,exports.removeLast=removeLast,exports.removeFirst=removeFirst,exports.insert=insert,exports.removeAt=removeAt,exports.replaceAt=replaceAt,exports.getIn=getIn,exports.set=set,exports.setIn=setIn,exports.updateIn=updateIn,exports.merge=merge,exports.mergeIn=mergeIn,exports.omit=omit,exports.addDefaults=addDefaults;/*!
* Timm

@@ -3,0 +3,0 @@ *

{
"name": "timm",
"version": "1.2.1",
"version": "1.2.2",
"description": "Immutability helpers with fast reads and acceptable writes",

@@ -5,0 +5,0 @@ "main": "lib/timm.js",

@@ -294,3 +294,4 @@ // @flow

export function set<T>(obj: ?T, key: Key, val: any): T {
const finalObj: any = obj == null ? {} : obj;
const fallback = Number.isInteger(key) ? [] : {};
const finalObj: any = obj == null ? fallback : obj;
if (finalObj[key] === val) return finalObj;

@@ -297,0 +298,0 @@ const obj2 = clone(finalObj);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc