✅ Complete Astro migration - PDPA compliant website
- Migrated all pages from Next.js to Astro - Added PDPA-compliant Privacy Policy (Thai) - Added PDPA-compliant Terms & Conditions (Thai) - Added Cookie Policy with disclosure (Thai) - Implemented cookie consent banner (client-side) - Integrated Umami Analytics placeholder - Blog system with 3 posts - Optimized Docker configuration for production - Static site build (184KB, 11 pages) - Ready for Easypanel deployment Backup: /Users/kunthawatgreethong/Gitea/dealplustech-backup-nextjs-20260309.tar.gz
This commit is contained in:
39
dealplustech-astro/node_modules/deep-diff/examples/apply-diff-from-any.js
generated
vendored
Normal file
39
dealplustech-astro/node_modules/deep-diff/examples/apply-diff-from-any.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/*jshint indent:2, laxcomma:true, laxbreak:true*/
|
||||
var util = require('util')
|
||||
, diff = require('..')
|
||||
, data = require('./practice-data')
|
||||
;
|
||||
|
||||
var cycle = -1
|
||||
, i
|
||||
, len = data.length
|
||||
, prior = {}
|
||||
, comparand
|
||||
, records
|
||||
, ch
|
||||
;
|
||||
|
||||
var applyEachChange = function (ch) {
|
||||
diff.applyChange(prior, comparand, ch);
|
||||
};
|
||||
|
||||
while (++cycle < 10) {
|
||||
i = -1;
|
||||
while (++i < len) {
|
||||
|
||||
comparand = data[i];
|
||||
|
||||
// get the difference...
|
||||
records = diff(prior, comparand);
|
||||
|
||||
// round-trip serialize to prune the underlying types...
|
||||
var serialized = JSON.stringify(records);
|
||||
var desierialized = JSON.parse(serialized);
|
||||
|
||||
if (desierialized) {
|
||||
desierialized.forEach(applyEachChange);
|
||||
|
||||
prior = comparand;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
dealplustech-astro/node_modules/deep-diff/examples/array-change.js
generated
vendored
Normal file
45
dealplustech-astro/node_modules/deep-diff/examples/array-change.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*jshint indent:2, laxcomma:true, laxbreak:true*/
|
||||
var util = require('util');
|
||||
var expect = require('expect.js');
|
||||
var deep = require('..');
|
||||
|
||||
var lhs = {
|
||||
'id': 'Release',
|
||||
'phases': [{
|
||||
'id': 'Phase1',
|
||||
'tasks': [
|
||||
{ 'id': 'Task1' },
|
||||
{ 'id': 'Task2' }
|
||||
]
|
||||
}, {
|
||||
'id': 'Phase2',
|
||||
'tasks': [
|
||||
{ 'id': 'Task3' }
|
||||
]
|
||||
}]
|
||||
};
|
||||
var rhs = {
|
||||
'id': 'Release',
|
||||
'phases': [{
|
||||
// E: Phase1 -> Phase2
|
||||
'id': 'Phase2',
|
||||
'tasks': [
|
||||
{ 'id': 'Task3' }
|
||||
]
|
||||
}, {
|
||||
'id': 'Phase1',
|
||||
'tasks': [
|
||||
{ 'id': 'Task1' },
|
||||
{ 'id': 'Task2' }
|
||||
]
|
||||
}]
|
||||
};
|
||||
|
||||
var diff = deep.diff(lhs, rhs);
|
||||
console.log(util.inspect(diff, false, 9)); // eslint-disable-line no-console
|
||||
|
||||
deep.applyDiff(lhs, rhs);
|
||||
console.log(util.inspect(lhs, false, 9)); // eslint-disable-line no-console
|
||||
|
||||
expect(lhs).to.be.eql(rhs);
|
||||
|
||||
53
dealplustech-astro/node_modules/deep-diff/examples/capture_change_apply_elsewhere.js
generated
vendored
Normal file
53
dealplustech-astro/node_modules/deep-diff/examples/capture_change_apply_elsewhere.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/*jshint indent:2, laxcomma:true, laxbreak:true*/
|
||||
var util = require('util')
|
||||
, assert = require('assert')
|
||||
, diff = require('..')
|
||||
, data = require('./practice-data')
|
||||
;
|
||||
|
||||
var i = Math.floor(Math.random() * data.length) + 1;
|
||||
var j = Math.floor(Math.random() * data.length) + 1;
|
||||
|
||||
while (j === i) {
|
||||
j = Math.floor(Math.random() * data.length) + 1;
|
||||
}
|
||||
|
||||
var source = data[i];
|
||||
var comparand = data[j];
|
||||
|
||||
// source and comparand are different objects
|
||||
assert.notEqual(source, comparand);
|
||||
|
||||
// source and comparand have differences in their structure
|
||||
assert.notDeepEqual(source, comparand);
|
||||
|
||||
// record the differences between source and comparand
|
||||
var changes = diff(source, comparand);
|
||||
|
||||
// apply the changes to the source
|
||||
changes.forEach(function (change) {
|
||||
diff.applyChange(source, true, change);
|
||||
});
|
||||
|
||||
// source and copmarand are now deep equal
|
||||
assert.deepEqual(source, comparand);
|
||||
|
||||
// Simulate serializing to a remote copy of the object (we've already go a copy, copy the changes)...
|
||||
|
||||
var remote = JSON.parse(JSON.stringify(source));
|
||||
var remoteChanges = JSON.parse(JSON.stringify(changes));
|
||||
|
||||
// source and remote are different objects
|
||||
assert.notEqual(source, remote);
|
||||
|
||||
// changes and remote changes are different objects
|
||||
assert.notEqual(changes, remoteChanges);
|
||||
|
||||
// remote and comparand are different objects
|
||||
assert.notEqual(remote, comparand);
|
||||
|
||||
remoteChanges.forEach(function (change) {
|
||||
diff.applyChange(remote, true, change);
|
||||
});
|
||||
|
||||
assert.deepEqual(remote, comparand);
|
||||
88
dealplustech-astro/node_modules/deep-diff/examples/diff-ignoring-fun.js
generated
vendored
Normal file
88
dealplustech-astro/node_modules/deep-diff/examples/diff-ignoring-fun.js
generated
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
/*jshint indent:2, laxcomma:true, laxbreak:true*/
|
||||
var util = require('util')
|
||||
, deep = require('..')
|
||||
;
|
||||
|
||||
function duckWalk() {
|
||||
util.log('right step, left-step, waddle');
|
||||
}
|
||||
|
||||
function quadrapedWalk() {
|
||||
util.log('right hind-step, right fore-step, left hind-step, left fore-step');
|
||||
}
|
||||
|
||||
var duck = {
|
||||
legs: 2,
|
||||
walk: duckWalk
|
||||
};
|
||||
|
||||
var dog = {
|
||||
legs: 4,
|
||||
walk: quadrapedWalk
|
||||
};
|
||||
|
||||
var diff = deep.diff(duck, dog);
|
||||
|
||||
// The differences will include the legs, and walk.
|
||||
util.log('Differences:\r\n' + util.inspect(diff, false, 9));
|
||||
|
||||
|
||||
// To ignore behavioral differences (functions); use observableDiff and your own accumulator:
|
||||
|
||||
var observed = [];
|
||||
deep.observableDiff(duck, dog, function (d) {
|
||||
if (d && d.lhs && typeof d.lhs !== 'function') {
|
||||
observed.push(d);
|
||||
}
|
||||
});
|
||||
|
||||
util.log('Observed without recording functions:\r\n' + util.inspect(observed, false, 9));
|
||||
|
||||
util.log(util.inspect(dog, false, 9) + ' walking: ');
|
||||
dog.walk();
|
||||
|
||||
// The purpose of the observableDiff fn is to allow you to observe and apply differences
|
||||
// that make sense in your scenario...
|
||||
|
||||
// We'll make the dog act like a duck...
|
||||
deep.observableDiff(dog, duck, function (d) {
|
||||
deep.applyChange(dog, duck, d);
|
||||
});
|
||||
|
||||
util.log(util.inspect(dog, false, 9) + ' walking: ');
|
||||
dog.walk();
|
||||
|
||||
// Now there are no differences between the duck and the dog:
|
||||
if (deep.diff(duck, dog)) {
|
||||
util.log("Ooops, that prior statement seems to be wrong! (but it won't be)");
|
||||
}
|
||||
|
||||
// Now assign an "equivalent" walk function...
|
||||
dog.walk = function duckWalk() {
|
||||
util.log('right step, left-step, waddle');
|
||||
};
|
||||
|
||||
if (diff = deep.diff(duck, dog)) {
|
||||
// The dog's walk function is an equivalent, but different duckWalk function.
|
||||
util.log('Hrmm, the dog walks differently: ' + util.inspect(diff, false, 9));
|
||||
}
|
||||
|
||||
// Use the observableDiff fn to ingore based on behavioral equivalence...
|
||||
|
||||
observed = [];
|
||||
deep.observableDiff(duck, dog, function (d) {
|
||||
// if the change is a function, only record it if the text of the fns differ:
|
||||
if (d && typeof d.lhs === 'function' && typeof d.rhs === 'function') {
|
||||
var leftFnText = d.lhs.toString();
|
||||
var rightFnText = d.rhs.toString();
|
||||
if (leftFnText !== rightFnText) {
|
||||
observed.push(d);
|
||||
}
|
||||
} else {
|
||||
observed.push(d);
|
||||
}
|
||||
});
|
||||
|
||||
if (observed.length === 0) {
|
||||
util.log('Yay!, we detected that the walk functions are equivalent');
|
||||
}
|
||||
49
dealplustech-astro/node_modules/deep-diff/examples/diff-scenarios.js
generated
vendored
Normal file
49
dealplustech-astro/node_modules/deep-diff/examples/diff-scenarios.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
var util = require('util'),
|
||||
expect = require('expect.js'),
|
||||
eql = require('deep-equal'),
|
||||
deep = require('..')
|
||||
extend = util._extend;
|
||||
diff = deep.diff,
|
||||
apply = deep.applyDiff;
|
||||
|
||||
function f0() {};
|
||||
function f1() {};
|
||||
|
||||
var one = { it: 'be one', changed: false, with: { nested: 'data'}, f: f1};
|
||||
var two = { it: 'be two', updated: true, changed: true, with: {nested: 'data', and: 'other', plus: one} };
|
||||
var circ = {};
|
||||
var other = { it: 'be other', numero: 34.29, changed: [ { it: 'is the same' }, 13.3, 'get some' ], with: {nested: 'reference', plus: circ} };
|
||||
var circular = extend(circ, { it: 'be circ', updated: false, changed: [ { it: 'is not same' }, 13.3, 'get some!', {extra: 'stuff'}], with: { nested: 'reference', circular: other } });
|
||||
|
||||
util.log(util.inspect(diff(one, two), false, 99));
|
||||
util.log(util.inspect(diff(two, one), false, 99));
|
||||
|
||||
util.log(util.inspect(diff(other, circular), false, 99));
|
||||
|
||||
var clone = extend({}, one);
|
||||
apply(clone, two);
|
||||
util.log(util.inspect(clone, false, 99));
|
||||
|
||||
expect(eql(clone, two)).to.be(true);
|
||||
expect(eql(clone, one)).to.be(false);
|
||||
|
||||
clone = extend({}, circular);
|
||||
apply(clone, other);
|
||||
util.log(util.inspect(clone, false, 99));
|
||||
expect(eql(clone, other)).to.be(true);
|
||||
expect(eql(clone, circular)).to.be(false);
|
||||
|
||||
|
||||
var array = { name: 'array two levels deep', item: { arr: ['it', { has: 'data' }]}};
|
||||
var arrayChange = { name: 'array change two levels deep', item: { arr: ['it', { changes: 'data' }]}};
|
||||
|
||||
util.log(util.inspect(diff(array, arrayChange), false, 99));
|
||||
clone = extend({}, array);
|
||||
apply(clone, arrayChange);
|
||||
util.log(util.inspect(clone, false, 99));
|
||||
expect(eql(clone, arrayChange)).to.be(true);
|
||||
|
||||
var one_prop = { one: 'property' };
|
||||
var d = diff(one_prop, {});
|
||||
expect(d.length).to.be(1);
|
||||
|
||||
41
dealplustech-astro/node_modules/deep-diff/examples/example1.js
generated
vendored
Normal file
41
dealplustech-astro/node_modules/deep-diff/examples/example1.js
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
var util = require('util')
|
||||
, deep = require('..')
|
||||
;
|
||||
|
||||
var lhs = {
|
||||
name: 'my object',
|
||||
description: 'it\'s an object!',
|
||||
details: {
|
||||
it: 'has',
|
||||
an: 'array',
|
||||
with: ['a', 'few', 'elements']
|
||||
}
|
||||
};
|
||||
|
||||
var rhs = {
|
||||
name: 'updated object',
|
||||
description: 'it\'s an object!',
|
||||
details: {
|
||||
it: 'has',
|
||||
an: 'array',
|
||||
with: ['a', 'few', 'more', 'elements', { than: 'before' }]
|
||||
}
|
||||
};
|
||||
|
||||
var differences = deep.diff(lhs, rhs);
|
||||
|
||||
// Print the differences to the console...
|
||||
util.log(util.inspect(differences, false, 99));
|
||||
|
||||
deep.observableDiff(lhs, rhs, function (d) {
|
||||
// Apply all changes except those to the 'name' property...
|
||||
if (d.path.length !== 1 || d.path.join('.') !== 'name') {
|
||||
deep.applyChange(lhs, rhs, d);
|
||||
}
|
||||
}, function (path, key) {
|
||||
var p = (path && path.length) ? path.join('/') : '<no-path>'
|
||||
util.log('prefilter: path = ' + p + ' key = ' + key);
|
||||
}
|
||||
);
|
||||
|
||||
console.log(util.inspect(lhs, false, 99));
|
||||
6
dealplustech-astro/node_modules/deep-diff/examples/issue-111.js
generated
vendored
Normal file
6
dealplustech-astro/node_modules/deep-diff/examples/issue-111.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var diff = require('../');
|
||||
|
||||
|
||||
var differences = diff(undefined, undefined);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(differences);
|
||||
14
dealplustech-astro/node_modules/deep-diff/examples/issue-113-1.js
generated
vendored
Normal file
14
dealplustech-astro/node_modules/deep-diff/examples/issue-113-1.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
const { log, inspect } = require('util');
|
||||
const assert = require('assert');
|
||||
const diff = require('../');
|
||||
|
||||
const o1 = {};
|
||||
const o2 = {};
|
||||
o1.foo = o1;
|
||||
o2.foo = o2;
|
||||
|
||||
assert.notEqual(o1, o2, 'not same object');
|
||||
assert.notEqual(o1.foo, o2.foo, 'not same object');
|
||||
|
||||
const differences = diff(o1, o2);
|
||||
log(inspect(differences, false, 9));
|
||||
11
dealplustech-astro/node_modules/deep-diff/examples/issue-113-2.js
generated
vendored
Normal file
11
dealplustech-astro/node_modules/deep-diff/examples/issue-113-2.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
const { log, inspect } = require('util');
|
||||
const diff = require('../');
|
||||
|
||||
var o1 = {};
|
||||
var o2 = {};
|
||||
o1.foo = o1;
|
||||
o2.foo = {foo: o2};
|
||||
const differences = diff(o1, o2);
|
||||
|
||||
log(inspect(differences, false, 9));
|
||||
|
||||
17
dealplustech-astro/node_modules/deep-diff/examples/issue-115.js
generated
vendored
Normal file
17
dealplustech-astro/node_modules/deep-diff/examples/issue-115.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
var diff = require('../');
|
||||
var expect = require('expect.js');
|
||||
|
||||
var thing1 = 'this';
|
||||
var thing2 = 'that';
|
||||
var thing3 = 'other';
|
||||
var thing4 = 'another';
|
||||
|
||||
var oldArray = [thing1, thing2, thing3, thing4];
|
||||
var newArray = [thing1, thing2];
|
||||
|
||||
diff.observableDiff(oldArray, newArray,
|
||||
function (d) {
|
||||
diff.applyChange(oldArray, d);
|
||||
});
|
||||
|
||||
expect(oldArray).to.eql(newArray);
|
||||
8
dealplustech-astro/node_modules/deep-diff/examples/issue-124.js
generated
vendored
Normal file
8
dealplustech-astro/node_modules/deep-diff/examples/issue-124.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
var diff = require('../');
|
||||
|
||||
var left = { key: [ {A: 0, B: 1}, {A: 2, B: 3} ] };
|
||||
var right = { key: [ {A: 9, B: 1}, {A: 2, B: 3} ] };
|
||||
|
||||
var differences = diff(left, right);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(differences);
|
||||
19
dealplustech-astro/node_modules/deep-diff/examples/issue-125.js
generated
vendored
Normal file
19
dealplustech-astro/node_modules/deep-diff/examples/issue-125.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var diff = require('../');
|
||||
|
||||
const left = {
|
||||
nested: {
|
||||
param1: null,
|
||||
param2: null
|
||||
}
|
||||
};
|
||||
|
||||
const right = {
|
||||
nested: {
|
||||
param1: null,
|
||||
param2: null
|
||||
}
|
||||
};
|
||||
|
||||
var differences = diff(left, right);
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(differences);
|
||||
33
dealplustech-astro/node_modules/deep-diff/examples/issue-126.js
generated
vendored
Normal file
33
dealplustech-astro/node_modules/deep-diff/examples/issue-126.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// This example shows how prefiltering can be used.
|
||||
|
||||
const diff = require('../'); // deep-diff
|
||||
const { log, inspect } = require('util');
|
||||
const assert = require('assert');
|
||||
|
||||
const data = {
|
||||
issue: 126,
|
||||
submittedBy: 'abuzarhamza',
|
||||
title: 'readme.md need some additional example prefilter',
|
||||
posts: [
|
||||
{
|
||||
date: '2018-04-16',
|
||||
text: `additional example for prefilter for deep-diff would be great.
|
||||
https://stackoverflow.com/questions/38364639/pre-filter-condition-deep-diff-node-js`
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const clone = JSON.parse(JSON.stringify(data));
|
||||
clone.title = 'README.MD needs additional example illustrating how to prefilter';
|
||||
clone.disposition = 'completed';
|
||||
|
||||
const two = diff(data, clone);
|
||||
const none = diff(data, clone,
|
||||
(path, key) => path.length === 0 && ~['title', 'disposition'].indexOf(key)
|
||||
);
|
||||
|
||||
assert.equal(two.length, 2, 'should reflect two differences');
|
||||
assert.ok(typeof none === 'undefined', 'should reflect no differences');
|
||||
|
||||
log(inspect(two, false, 9));
|
||||
log(inspect(none, false, 9));
|
||||
11
dealplustech-astro/node_modules/deep-diff/examples/issue-35.js
generated
vendored
Normal file
11
dealplustech-astro/node_modules/deep-diff/examples/issue-35.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
var deep = require('../');
|
||||
|
||||
var lhs = ['a', 'a'];
|
||||
var rhs = ['a'];
|
||||
var differences = deep.diff(lhs, rhs);
|
||||
differences.forEach(function (change) {
|
||||
deep.applyChange(lhs, true, change);
|
||||
});
|
||||
|
||||
console.log(lhs); // eslint-disable-line no-console
|
||||
console.log(rhs); // eslint-disable-line no-console
|
||||
17
dealplustech-astro/node_modules/deep-diff/examples/issue-47.js
generated
vendored
Normal file
17
dealplustech-astro/node_modules/deep-diff/examples/issue-47.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
var diff = require('../');
|
||||
var expect = require('expect.js');
|
||||
|
||||
var thing1 = 'this';
|
||||
var thing2 = 'that';
|
||||
var thing3 = 'other';
|
||||
var thing4 = 'another';
|
||||
|
||||
var oldArray = [thing1, thing2, thing3, thing4];
|
||||
var newArray = [thing1, thing2];
|
||||
|
||||
diff.observableDiff(oldArray, newArray,
|
||||
function (d) {
|
||||
diff.applyChange(oldArray, newArray, d);
|
||||
});
|
||||
|
||||
expect(oldArray).to.eql(newArray);
|
||||
48
dealplustech-astro/node_modules/deep-diff/examples/issue-48.js
generated
vendored
Normal file
48
dealplustech-astro/node_modules/deep-diff/examples/issue-48.js
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
|
||||
var dd = require('../'); // deep-diff
|
||||
var inspect = require('util').inspect;
|
||||
var expect = require('expect.js');
|
||||
|
||||
var before = {
|
||||
name: 'my object',
|
||||
description: 'it\'s an object!',
|
||||
details: {
|
||||
it: 'has',
|
||||
an: 'array',
|
||||
with: ['a', 'few', 'elements']
|
||||
}
|
||||
};
|
||||
|
||||
var after = {
|
||||
name: 'updated object',
|
||||
description: 'it\'s an object!',
|
||||
details: {
|
||||
it: 'has',
|
||||
an: 'array',
|
||||
with: ['a', 'few', 'more', 'elements', { than: 'before' }]
|
||||
}
|
||||
};
|
||||
|
||||
var revertDiff = function (src, d) {
|
||||
d.forEach(function (change) {
|
||||
dd.revertChange(src, true, change);
|
||||
});
|
||||
return src;
|
||||
};
|
||||
|
||||
var clone = function (src) {
|
||||
return JSON.parse(JSON.stringify(src));
|
||||
};
|
||||
|
||||
var df = dd.diff(before, after);
|
||||
var b1 = clone(before);
|
||||
var a1 = clone(after);
|
||||
|
||||
console.log(inspect(a1, false, 9)); // eslint-disable-line no-console
|
||||
|
||||
var reverted = revertDiff(a1, df);
|
||||
console.log(inspect(reverted, false, 9)); // eslint-disable-line no-console
|
||||
console.log(inspect(b1, false, 9)); // eslint-disable-line no-console
|
||||
|
||||
expect(reverted).to.eql(b1);
|
||||
|
||||
14
dealplustech-astro/node_modules/deep-diff/examples/issue-62.js
generated
vendored
Normal file
14
dealplustech-astro/node_modules/deep-diff/examples/issue-62.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
var deep = require("../");
|
||||
|
||||
// https://github.com/flitbit/diff/issues/62#issuecomment-229549984
|
||||
// 3: appears to be fixed, probably in fixing #74.
|
||||
|
||||
var a = {};
|
||||
var b = {};
|
||||
a.x = b;
|
||||
b.x = b;
|
||||
deep.diff(a, b); // True
|
||||
|
||||
a.x = a; // Change to a
|
||||
// No change to b
|
||||
console.log(deep.diff(a, b)); // Still true...
|
||||
6
dealplustech-astro/node_modules/deep-diff/examples/issue-70.js
generated
vendored
Normal file
6
dealplustech-astro/node_modules/deep-diff/examples/issue-70.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var deepDiff = require('../');
|
||||
|
||||
var left = {foo: undefined};
|
||||
var right = {};
|
||||
|
||||
console.log(deepDiff.diff(left, right)); // eslint-disable-line no-console
|
||||
15
dealplustech-astro/node_modules/deep-diff/examples/issue-71.js
generated
vendored
Normal file
15
dealplustech-astro/node_modules/deep-diff/examples/issue-71.js
generated
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
var diff = require('../');
|
||||
|
||||
var left = {
|
||||
left: 'yes',
|
||||
right: 'no',
|
||||
};
|
||||
|
||||
var right = {
|
||||
left: {
|
||||
toString: true,
|
||||
},
|
||||
right: 'no',
|
||||
};
|
||||
|
||||
console.log(diff(left, right)); // eslint-disable-line no-console
|
||||
21
dealplustech-astro/node_modules/deep-diff/examples/issue-72.js
generated
vendored
Normal file
21
dealplustech-astro/node_modules/deep-diff/examples/issue-72.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
var diff = require('../');
|
||||
|
||||
var before = {
|
||||
data: [1, 2, 3]
|
||||
};
|
||||
|
||||
var after = {
|
||||
data: [4, 5, 1]
|
||||
};
|
||||
|
||||
var differences = diff(before, after);
|
||||
console.log(differences); // eslint-disable-line no-console
|
||||
differences.reduce(
|
||||
(acc, change) => {
|
||||
diff.revertChange(acc, true, change);
|
||||
return acc;
|
||||
},
|
||||
after
|
||||
);
|
||||
|
||||
console.log(after); // eslint-disable-line no-console
|
||||
9
dealplustech-astro/node_modules/deep-diff/examples/issue-74.js
generated
vendored
Normal file
9
dealplustech-astro/node_modules/deep-diff/examples/issue-74.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var deepDiff = require("../");
|
||||
|
||||
var a = {prop: {}};
|
||||
var b = {prop: {}};
|
||||
|
||||
a.prop.circ = a.prop;
|
||||
b.prop.circ = b;
|
||||
|
||||
console.log(deepDiff.diff(a, b));
|
||||
24
dealplustech-astro/node_modules/deep-diff/examples/issue-78.js
generated
vendored
Normal file
24
dealplustech-astro/node_modules/deep-diff/examples/issue-78.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
const diff = require('../');
|
||||
const ptr = require('json-ptr');
|
||||
|
||||
const inspect = require('util').inspect;
|
||||
|
||||
|
||||
const objA = { array: [{ a: 1 }] };
|
||||
const objB = { array: [{ a: 2 }] };
|
||||
|
||||
let changes = diff(objA, objB);
|
||||
if (changes) {
|
||||
// decorate the changes using json-pointers
|
||||
for (let i = 0; i < changes.length; ++i) {
|
||||
let change = changes[i];
|
||||
// get the parent path:
|
||||
let pointer = ptr.create(change.path.slice(0, change.path.length - 1));
|
||||
if (change.kind === 'E') {
|
||||
change.elementLeft = pointer.get(objA);
|
||||
change.elementRight = pointer.get(objB);
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(inspect(changes, false, 9)); // eslint-disable-line no-console
|
||||
11
dealplustech-astro/node_modules/deep-diff/examples/issue-83.js
generated
vendored
Normal file
11
dealplustech-astro/node_modules/deep-diff/examples/issue-83.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
var deepDiff = require("../");
|
||||
|
||||
var left = {
|
||||
date: null
|
||||
};
|
||||
|
||||
var right = {
|
||||
date: null
|
||||
};
|
||||
|
||||
console.log(deepDiff(left, right));
|
||||
26
dealplustech-astro/node_modules/deep-diff/examples/issue-88.js
generated
vendored
Normal file
26
dealplustech-astro/node_modules/deep-diff/examples/issue-88.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
var diff = require("../");
|
||||
|
||||
var before = {
|
||||
length: 3,
|
||||
data: [1, 2, 3]
|
||||
};
|
||||
|
||||
var after = {
|
||||
data: [4, 5, 1, 2, 3],
|
||||
count: 5
|
||||
};
|
||||
|
||||
var differences = diff(before, after);
|
||||
console.log(differences);
|
||||
|
||||
function applyChanges(target, changes) {
|
||||
return changes.reduce(
|
||||
(acc, change) => {
|
||||
diff.applyChange(acc, true, change);
|
||||
return acc;
|
||||
},
|
||||
target
|
||||
);
|
||||
}
|
||||
|
||||
console.log(applyChanges(before, differences));
|
||||
64
dealplustech-astro/node_modules/deep-diff/examples/performance.js
generated
vendored
Normal file
64
dealplustech-astro/node_modules/deep-diff/examples/performance.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
var util = require('util')
|
||||
, diff = require('..')
|
||||
, data = require('./practice-data')
|
||||
;
|
||||
|
||||
var cycle = -1
|
||||
, i
|
||||
, len = data.length
|
||||
, prior = {}
|
||||
, comparand
|
||||
, records
|
||||
, roll = []
|
||||
, stat
|
||||
, stats = []
|
||||
, mark, elapsed, avg = { diff: { ttl: 0 }, apply: { ttl: 0 } }, ttl = 0
|
||||
;
|
||||
|
||||
mark = process.hrtime();
|
||||
while (++cycle < 10) {
|
||||
i = -1;
|
||||
while (++i < len) {
|
||||
stats.push(stat = { mark: process.hrtime() });
|
||||
|
||||
comparand = roll[i] || data[i];
|
||||
|
||||
stat.diff = { mark: process.hrtime() };
|
||||
records = diff(prior, comparand);
|
||||
stat.diff.intv = process.hrtime(stat.diff.mark);
|
||||
|
||||
if (records) {
|
||||
stat.apply = { count: diff.length, mark: process.hrtime() };
|
||||
records.forEach(function (ch) {
|
||||
diff.applyChange(prior, comparand, ch);
|
||||
});
|
||||
stat.apply.intv = process.hrtime(stat.apply.mark);
|
||||
|
||||
prior = comparand;
|
||||
}
|
||||
stat.intv = process.hrtime(stat.mark);
|
||||
}
|
||||
}
|
||||
|
||||
function ms(intv) {
|
||||
return (intv[0] * 1e9 + intv[1] / 1e6);
|
||||
}
|
||||
elapsed = ms(process.hrtime(mark));
|
||||
|
||||
stats.forEach(function (stat) {
|
||||
stat.elapsed = ms(stat.intv);
|
||||
stat.diff.elapsed = ms(stat.diff.intv);
|
||||
avg.diff.ttl += stat.diff.elapsed;
|
||||
if (stat.apply) {
|
||||
stat.apply.elapsed = ms(stat.apply.intv);
|
||||
ttl += stat.apply.count;
|
||||
avg.apply.ttl += stat.apply.elapsed;
|
||||
}
|
||||
});
|
||||
|
||||
avg.diff.avg = avg.diff.ttl / ttl;
|
||||
avg.apply.avg = avg.apply.ttl / ttl;
|
||||
|
||||
console.log('Captured '.concat(stats.length, ' samples with ', ttl, ' combined differences in ', elapsed, 'ms'));
|
||||
console.log('\tavg diff: '.concat(avg.diff.avg, 'ms or ', (1 / avg.diff.avg), ' per ms'));
|
||||
console.log('\tavg apply: '.concat(avg.apply.avg, 'ms or ', (1 / avg.apply.avg), ' per ms'));
|
||||
2501
dealplustech-astro/node_modules/deep-diff/examples/practice-data.json
generated
vendored
Normal file
2501
dealplustech-astro/node_modules/deep-diff/examples/practice-data.json
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user