Socket
Socket
Sign inDemoInstall

rfc6902-ordered

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rfc6902-ordered - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

src/add-to-object-at-index.js

6

package.json
{
"name": "rfc6902-ordered",
"version": "1.0.2",
"version": "1.0.3",
"description": "https://github.com/chbrown/rfc6902 plus object key ordering",

@@ -32,6 +32,6 @@ "main": "src/index.js",

"eslint": "^4.6.1",
"eslint-config-sane": "^0.1.0",
"eslint-config-sane": "^0.2.0",
"eslint-plugin-mocha": "^4.11.0",
"mocha": "^3.5.1"
"mocha": "^4.0.0"
}
}
'use strict';
const rfc6902 = require('rfc6902');
const addToObjectAtIndex = require('./add-to-object-at-index');
const _applyPatch = rfc6902.applyPatch;
module.exports = rfc6902;
function addToObjectAtIndex(obj, key, value, index) {
let result = {};
let keys = Object.keys(obj);
for (let i = 0; i < keys.length; i++) {
if (i === index) {
result[key] = value;
}
let k = keys[i];
result[k] = obj[k];
}
if (index === keys.length) {
result[key] = value;
}
// mutate the original object because it we like that
// it is already linked somewhere in the package.json tree
for (let key in obj) {
delete obj[key];
}
for (let key in result) {
obj[key] = result[key];
}
}
function get(obj, parts) {

@@ -42,3 +14,3 @@ return parts.reduce((total, next) => {

module.exports.applyPatch = function applyPatch(myPackageJson, patch, toPackageJson) {
function applyPatch(myPackageJson, patch, toPackageJson) {
if (arguments.length > 2) {

@@ -94,2 +66,5 @@ patch = patch.slice();

return _applyPatch.call(this, myPackageJson, patch);
};
}
module.exports = rfc6902;
module.exports.applyPatch = applyPatch;
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