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

camel-dot-prop-immutable

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

camel-dot-prop-immutable - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

127

dist/index.js

@@ -7,4 +7,18 @@ "use strict";

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _extends2 = require("babel-runtime/helpers/extends");
var _extends3 = _interopRequireDefault(_extends2);
var _keys = require("babel-runtime/core-js/object/keys");
var _keys2 = _interopRequireDefault(_keys);
var _defineProperty2 = require("babel-runtime/helpers/defineProperty");
var _defineProperty3 = _interopRequireDefault(_defineProperty2);
var _getIterator2 = require("babel-runtime/core-js/get-iterator");
var _getIterator3 = _interopRequireDefault(_getIterator2);
var _dotPropImmutable = require("dot-prop-immutable");

@@ -16,15 +30,39 @@

function camelDotMatch({ obj, prop }) {
let result;
function camelDotMatch(_ref) {
var obj = _ref.obj,
prop = _ref.prop;
for (let combo of camelCombos(prop)) {
result = _dotPropImmutable2.default.get(obj, combo);
var result = void 0;
if (result) {
prop = combo;
break;
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = (0, _getIterator3.default)(camelCombos(prop)), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var combo = _step.value;
result = _dotPropImmutable2.default.get(obj, combo);
if (result) {
prop = combo;
break;
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
return { prop, result };
return { prop: prop, result: result };
}

@@ -34,3 +72,5 @@

if (Array.isArray(prop)) {
prop = prop.map(p => p.replace(".", "\\."));
prop = prop.map(function (p) {
return p.replace(".", "\\.");
});
prop = prop.join(".");

@@ -43,20 +83,43 @@ }

function camelStringCombos(prop) {
let regexes = [/[^\\]\.\w/, /[^\\]\.[^.]+$/];
let combos = { [prop]: null };
let ogProp = prop;
var regexes = [/[^\\]\.\w/, /[^\\]\.[^.]+$/];
var combos = (0, _defineProperty3.default)({}, prop, null);
var ogProp = prop;
for (let regex of regexes) {
prop = ogProp;
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
do {
prop = prop.replace(regex, match => match.charAt(0) + match.charAt(2).toUpperCase() + match.slice(3));
combos[prop] = null;
} while (prop.match(regex));
try {
for (var _iterator2 = (0, _getIterator3.default)(regexes), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var regex = _step2.value;
prop = ogProp;
do {
prop = prop.replace(regex, function (match) {
return match.charAt(0) + match.charAt(2).toUpperCase() + match.slice(3);
});
combos[prop] = null;
} while (prop.match(regex));
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
return Object.keys(combos);
return (0, _keys2.default)(combos);
}
function get(obj, prop, value) {
let match = camelDotMatch({ obj, prop });
var match = camelDotMatch({ obj: obj, prop: prop });

@@ -71,3 +134,3 @@ if (typeof match.result === "undefined") {

function set(obj, prop, value) {
let match = camelDotMatch({ obj, prop });
var match = camelDotMatch({ obj: obj, prop: prop });
return _dotPropImmutable2.default.set(obj, match.prop, value);

@@ -77,3 +140,3 @@ }

function _delete(obj, prop) {
let match = camelDotMatch({ obj, prop });
var match = camelDotMatch({ obj: obj, prop: prop });
return _dotPropImmutable2.default.delete(obj, match.prop);

@@ -83,3 +146,3 @@ }

function toggle(obj, prop) {
let match = camelDotMatch({ obj, prop });
var match = camelDotMatch({ obj: obj, prop: prop });
return _dotPropImmutable2.default.toggle(obj, match.prop);

@@ -89,14 +152,14 @@ }

function merge(obj, prop, value) {
let match = camelDotMatch({ obj, prop });
var match = camelDotMatch({ obj: obj, prop: prop });
return _dotPropImmutable2.default.merge(obj, match.prop, value);
}
exports.default = _extends({}, _dotPropImmutable2.default, {
camelCombos,
camelDotMatch,
exports.default = (0, _extends3.default)({}, _dotPropImmutable2.default, {
camelCombos: camelCombos,
camelDotMatch: camelDotMatch,
delete: _delete,
get,
merge,
set,
toggle
get: get,
merge: merge,
set: set,
toggle: toggle
});
{
"name": "camel-dot-prop-immutable",
"version": "1.4.1",
"version": "1.5.0",
"description":

@@ -31,24 +31,36 @@ "dot-prop-immutable w/ check for flattened props",

"devDependencies": {
"babel-core": "6",
"babel-plugin-transform-async-to-generator": "6",
"babel-plugin-transform-object-rest-spread": "6",
"babel-preset-node6": "11",
"eslint": "4",
"babel-cli": "6",
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1",
"eslint": "^4.19.1",
"eslint-config-prettier": "2",
"eslint-plugin-prettier": "2",
"husky": "^0.15.0-rc.3",
"jest": "22",
"lint-staged": "6",
"prettier": "1",
"webpack": "3"
"husky": "^0.15.0-rc.13",
"jest": "^22.4.3",
"lint-staged": "^6.1.1",
"prettier": "^1.12.1",
"webpack": "^3.11.0"
},
"dependencies": {
"babel-runtime": "^6.26.0",
"dot-prop-immutable": "^1.4.0"
},
"babel": {
"presets": ["node6"],
"plugins": [
"transform-async-to-generator",
"transform-object-rest-spread"
]
"presets": [
[
"env",
{
"targets": {
"node": "current",
"uglify": true,
"useBuiltIns": true
}
}
],
"stage-0"
],
"plugins": ["transform-runtime"]
},

@@ -55,0 +67,0 @@ "eslintConfig": {

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