Socket
Socket
Sign inDemoInstall

rfc6902

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rfc6902 - npm Package Compare versions

Comparing version 3.1.1 to 4.0.0

18

diff.d.ts

@@ -117,3 +117,21 @@ import { Pointer } from './pointer';

that would transform `input` into `output`.
> Here, "equal" means that the value at the target location and the
> value conveyed by "value" are of the same JSON type, and that they
> are considered equal by the following rules for that type:
> o strings: are considered equal if they contain the same number of
> Unicode characters and their code points are byte-by-byte equal.
> o numbers: are considered equal if their values are numerically
> equal.
> o arrays: are considered equal if they contain the same number of
> values, and if each value can be considered equal to the value at
> the corresponding position in the other array, using this list of
> type-specific rules.
> o objects: are considered equal if they contain the same number of
> members, and if each member can be considered equal to a member in
> the other object, by comparing their keys (as strings) and their
> values (using this list of type-specific rules).
> o literals (false, true, and null): are considered equal if they are
> the same.
*/
export declare function diffAny(input: any, output: any, ptr: Pointer, diff?: Diff): Operation[];

23

diff.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.diffAny = exports.diffObjects = exports.diffArrays = exports.intersection = exports.subtract = exports.isDestructive = void 0;
var equal_1 = require("./equal");
var pointer_1 = require("./pointer"); // we only need this for type inference
var util_1 = require("./util");

@@ -135,3 +135,4 @@ function isDestructive(_a) {

if (memoized === undefined) {
if (i > 0 && j > 0 && equal_1.compare(input[i - 1], output[j - 1])) {
// TODO: this !diff(...).length usage could/should be lazy
if (i > 0 && j > 0 && !diff(input[i - 1], output[j - 1], new pointer_1.Pointer()).length) {
// equal (no operations => no cost)

@@ -244,2 +245,20 @@ memoized = dist(i - 1, j - 1);

that would transform `input` into `output`.
> Here, "equal" means that the value at the target location and the
> value conveyed by "value" are of the same JSON type, and that they
> are considered equal by the following rules for that type:
> o strings: are considered equal if they contain the same number of
> Unicode characters and their code points are byte-by-byte equal.
> o numbers: are considered equal if their values are numerically
> equal.
> o arrays: are considered equal if they contain the same number of
> values, and if each value can be considered equal to the value at
> the corresponding position in the other array, using this list of
> type-specific rules.
> o objects: are considered equal if they contain the same number of
> members, and if each member can be considered equal to a member in
> the other object, by comparing their keys (as strings) and their
> values (using this list of type-specific rules).
> o literals (false, true, and null): are considered equal if they are
> the same.
*/

@@ -246,0 +265,0 @@ function diffAny(input, output, ptr, diff) {

2

package.json
{
"name": "rfc6902",
"version": "3.1.1",
"version": "4.0.0",
"description": "Complete implementation of RFC6902 (patch and diff)",

@@ -5,0 +5,0 @@ "keywords": [

@@ -19,3 +19,3 @@ "use strict";

var util_1 = require("./util");
var equal_1 = require("./equal");
var diff_1 = require("./diff");
var MissingError = /** @class */ (function (_super) {

@@ -198,4 +198,4 @@ __extends(MissingError, _super);

var endpoint = pointer_1.Pointer.fromJSON(operation.path).evaluate(object);
var result = equal_1.compare(endpoint.value, operation.value);
if (!result) {
// TODO: this diffAny(...).length usage could/should be lazy
if (diff_1.diffAny(endpoint.value, operation.value, new pointer_1.Pointer()).length) {
return new TestError(endpoint.value, operation.value);

@@ -202,0 +202,0 @@ }

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