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.1.0 to 1.2.0

.eslintrc.json

27

dist/index.js

@@ -82,3 +82,3 @@ (function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap

function get(obj, prop, value) {
let match = getFlat({ obj, prop });
let match = getCamel({ obj, prop });
return match.result || value;

@@ -88,3 +88,3 @@ }

function set(obj, prop, value) {
let match = getFlat({ obj, prop });
let match = getCamel({ obj, prop });
return _dotPropImmutable2.default.set(obj, match.prop, value);

@@ -94,3 +94,3 @@ }

function _delete(obj, prop) {
let match = getFlat({ obj, prop });
let match = getCamel({ obj, prop });
return _dotPropImmutable2.default.delete(obj, match.prop);

@@ -100,3 +100,3 @@ }

function toggle(obj, prop) {
let match = getFlat({ obj, prop });
let match = getCamel({ obj, prop });
return _dotPropImmutable2.default.toggle(obj, match.prop);

@@ -106,8 +106,10 @@ }

function merge(obj, prop, value) {
let match = getFlat({ obj, prop });
let match = getCamel({ obj, prop });
return _dotPropImmutable2.default.merge(obj, match.prop, value);
}
function getFlat({ obj, prop }) {
function getCamel({ obj, prop }) {
let ogProp = prop;
let result = _dotPropImmutable2.default.get(obj, prop);
if (!result && prop.constructor === String) {

@@ -121,6 +123,17 @@ let lastProp;

}
if (result === undefined) {
prop = ogProp;
}
return { prop, result };
}
module.exports = _extends({}, _dotPropImmutable2.default, { get, set, delete: _delete, toggle, merge });
module.exports = _extends({}, _dotPropImmutable2.default, {
delete: _delete,
get,
merge,
set,
toggle
});

@@ -127,0 +140,0 @@ /***/ }),

import dot from "dot-prop-immutable"
function get(obj, prop, value) {
let match = getFlat({ obj, prop })
return (match.result || value)
let match = getCamel({ obj, prop })
return match.result || value
}
function set(obj, prop, value) {
let match = getFlat({ obj, prop })
let match = getCamel({ obj, prop })
return dot.set(obj, match.prop, value)

@@ -14,3 +14,3 @@ }

function _delete(obj, prop) {
let match = getFlat({ obj, prop })
let match = getCamel({ obj, prop })
return dot.delete(obj, match.prop)

@@ -20,3 +20,3 @@ }

function toggle(obj, prop) {
let match = getFlat({ obj, prop })
let match = getCamel({ obj, prop })
return dot.toggle(obj, match.prop)

@@ -26,8 +26,10 @@ }

function merge(obj, prop, value) {
let match = getFlat({ obj, prop })
let match = getCamel({ obj, prop })
return dot.merge(obj, match.prop, value)
}
function getFlat({ obj, prop }) {
function getCamel({ obj, prop }) {
let ogProp = prop
let result = dot.get(obj, prop)
if (!result && prop.constructor === String) {

@@ -43,5 +45,17 @@ let lastProp

}
if (result === undefined) {
prop = ogProp
}
return { prop, result }
}
module.exports = { ...dot, get, set, delete: _delete, toggle, merge }
module.exports = {
...dot,
delete: _delete,
get,
merge,
set,
toggle,
}
{
"name": "camel-dot-prop-immutable",
"version": "1.1.0",
"description": "dot-prop-immutable w/ check for flattened props",
"version": "1.2.0",
"description":
"dot-prop-immutable w/ check for flattened props",
"main": "dist/index.js",
"scripts": {
"build": "webpack",
"docs": "doctoc --notitle README.md",
"prepublishOnly": "npm run build",
"start": "doctoc --notitle README.md",
"start":
"eslint --ignore-path .gitignore --fix --ext=js .",
"test": "jest test"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged && npm test"
}
},
"lint-staged": {
"*.{json,css,md}": ["prettier --write", "git add"],
"*.js": [
"eslint --ignore-path .gitignore --fix",
"git add"
]
},
"prettier": {
"printWidth": 60,
"semi": false,
"trailingComma": "es5"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/invrs/camel-dot-prop-immutable.git"
"url":
"git+ssh://git@github.com/invrs/camel-dot-prop-immutable.git"
},
"keywords": [
"immutable",
"object",
"merge"
],
"keywords": ["immutable", "object", "merge"],
"author": "Winton Welsh <winton@cyclo.ps>",
"license": "MIT",
"bugs": {
"url": "https://github.com/invrs/camel-dot-prop-immutable/issues"
"url":
"https://github.com/invrs/camel-dot-prop-immutable/issues"
},
"homepage": "https://github.com/invrs/camel-dot-prop-immutable#readme",
"homepage":
"https://github.com/invrs/camel-dot-prop-immutable#readme",
"devDependencies": {

@@ -34,3 +53,9 @@ "babel-core": "^6.26.0",

"doctoc": "^1.3.0",
"eslint": "^4.16.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-prettier": "^2.5.0",
"husky": "^0.15.0-rc.3",
"jest": "^22.0.4",
"lint-staged": "^6.1.0",
"prettier": "^1.10.2",
"webpack": "^3.10.0"

@@ -37,0 +62,0 @@ },

@@ -8,10 +8,13 @@ # camel-dot-prop-immutable

dot.get({foo: {bar: { buzz: 'unicorn'}}}, 'foo.bar.buzz')
dot.get(
{ foo: { bar: { buzz: "unicorn" } } },
"foo.bar.buzz"
)
//=> 'unicorn'
dot.get({fooBar: { buzz: 'unicorn'}}, 'foo.bar.buzz')
dot.get({ fooBar: { buzz: "unicorn" } }, "foo.bar.buzz")
//=> 'unicorn'
dot.get({fooBarBuzz: 'unicorn'}, 'foo.bar.buzz')
dot.get({ fooBarBuzz: "unicorn" }, "foo.bar.buzz")
//=> 'unicorn'
```
import dot from "../lib"
test("get", () => {
expect(dot.get({foo: {bar: { buzz: 'unicorn'}}}, 'foo.bar.buzz'))
.toBe("unicorn")
expect(
dot.get(
{ foo: { bar: { buzz: "unicorn" } } },
"foo.bar.buzz"
)
).toBe("unicorn")
expect(dot.get({fooBar: { buzz: 'unicorn'}}, 'foo.bar.buzz'))
.toBe("unicorn")
expect(
dot.get({ fooBar: { buzz: "unicorn" } }, "foo.bar.buzz")
).toBe("unicorn")
expect(dot.get({fooBarBuzz: 'unicorn'}, 'foo.bar.buzz'))
.toBe("unicorn")
expect(
dot.get({ fooBarBuzz: "unicorn" }, "foo.bar.buzz")
).toBe("unicorn")
})
test("set", () => {
expect(dot.set({foo: {bar: 'a'}}, 'foo.bar', 'b'))
.toEqual({foo: {bar: 'b'}})
expect(
dot.set({ foo: { bar: "a" } }, "foo.bar", "b")
).toEqual({ foo: { bar: "b" } })
expect(dot.set({fooBar: 'a'}, 'foo.bar', 'b'))
.toEqual({fooBar: 'b'})
expect(dot.set({ foo: {} }, "foo.bar", "b")).toEqual({
foo: { bar: "b" },
})
expect(dot.set({ fooBar: "a" }, "foo.bar", "b")).toEqual({
fooBar: "b",
})
})
test("delete", () => {
expect(dot.delete({foo: {bar: 'a'}}, 'foo.bar'))
.toEqual({foo: {}})
expect(
dot.delete({ foo: { bar: "a" } }, "foo.bar")
).toEqual({ foo: {} })
expect(dot.delete({fooBar: 'a'}, 'foo.bar'))
.toEqual({})
expect(dot.delete({ fooBar: "a" }, "foo.bar")).toEqual({})
})
test("toggle", () => {
expect(dot.toggle({foo: {bar: true}}, 'foo.bar'))
.toEqual({foo: {bar: false}})
expect(
dot.toggle({ foo: { bar: true } }, "foo.bar")
).toEqual({ foo: { bar: false } })
expect(dot.toggle({fooBar: true}, 'foo.bar'))
.toEqual({fooBar: false})
expect(dot.toggle({ fooBar: true }, "foo.bar")).toEqual({
fooBar: false,
})
})
test("merge", () => {
expect(dot.merge({foo: {bar: {buzz: 'a'}}}, 'foo.bar', {bang: 'b'}))
.toEqual({foo: {bar: {buzz: 'a', bang: 'b'}}})
expect(
dot.merge({ foo: { bar: { bang: "a" } } }, "foo.bar", {
buzz: "b",
})
).toEqual({ foo: { bar: { bang: "a", buzz: "b" } } })
expect(dot.merge({fooBar: {buzz: 'a'}}, 'foo.bar', {bang: 'b'}))
.toEqual({fooBar: {buzz: 'a', bang: 'b'}})
expect(
dot.merge({ fooBar: { bang: "a" } }, "foo.bar", {
buzz: "b",
})
).toEqual({ fooBar: { bang: "a", buzz: "b" } })
})

@@ -1,5 +0,6 @@

var path = require('path')
var path = require("path")
module.exports = {
entry: path.join(__dirname, 'lib/index.js'),
entry: path.join(__dirname, "lib/index.js"),
externals: "dot-prop-immutable",
module: {

@@ -10,23 +11,20 @@ rules: [

use: {
loader: 'babel-loader',
loader: "babel-loader",
options: {
"presets": [
"node6"
plugins: [
"transform-async-to-generator",
"transform-object-rest-spread",
],
"plugins": [
"transform-async-to-generator",
"transform-object-rest-spread"
]
}
}
}
]
presets: ["node6"],
},
},
},
],
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js',
libraryTarget: 'commonjs'
filename: "index.js",
libraryTarget: "commonjs",
path: path.join(__dirname, "dist"),
},
target: 'node',
externals: 'dot-prop-immutable'
target: "node",
}
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