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:
Kunthawat Greethong
2026-03-09 18:28:01 +07:00
parent 668f69048f
commit 6402d885f9
6183 changed files with 463899 additions and 1913 deletions

View File

@@ -0,0 +1,76 @@
version: 2
jobs:
build:
working_directory: ~/repo
docker:
- image: circleci/node:8.11.3
steps:
- checkout
- run:
name: authorize npm
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: run npm install
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run: mkdir ~/junit
- run:
name: build & test
command: npm run ci
when: always
- run: cp test-results.xml ~/junit/test-results.xml
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
build_deploy_npm:
working_directory: ~/repo
docker:
- image: circleci/node:8.11.3
steps:
- checkout
- run:
name: authorize npm
command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: run npm install
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run: mkdir ~/junit
- run:
name: build & test
command: npm run ci
when: always
- run: cp test-results.xml ~/junit/test-results.xml
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
- run:
name: publish package to npm
command: npm publish
workflows:
version: 2
build_deploy:
jobs:
- build:
context: secrets
- build_deploy_npm:
context: secrets
filters:
tags:
only: /.*/
branches:
ignore: /.*/

72
dealplustech-astro/node_modules/deep-diff/.eslintrc generated vendored Normal file
View File

@@ -0,0 +1,72 @@
{
"parserOptions": {
"sourceType": "module"
},
"env": {
"node": true,
"browser": true
},
"extends": "eslint:recommended",
"rules": {
"no-alert": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-implied-eval": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-new": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-process-exit": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-undef-init": 2,
"no-underscore-dangle": 0,
"no-unused-expressions": 2,
"no-use-before-define": 2,
"no-with": 2,
"camelcase": 1,
"comma-spacing": 2,
"consistent-return": 2,
"curly": [ 2, "all" ],
"dot-notation": [ 2, { "allowKeywords": true } ],
"eol-last": 2,
"no-extra-parens": [ 2, "functions" ],
"eqeqeq": 2,
"keyword-spacing": [ 2, { "before": true, "after": true } ],
"key-spacing": [ 2, { "beforeColon": false, "afterColon": true } ],
"new-cap": 2,
"new-parens": 2,
"quotes": [ 2, "single" ],
"semi": 2,
"semi-spacing": [ 2, { "before": false, "after": true } ],
"space-infix-ops": 2,
"space-unary-ops": [ 2, { "words": true, "nonwords": false } ],
"strict": [ 2, "global" ],
"yoda": [ 2, "never" ]
},
"overrides": [
{
"files": [ "*.js", "test/*.js" ],
"excludedFiles": "examples/*.js"
}
]
}

63
dealplustech-astro/node_modules/deep-diff/ChangeLog.md generated vendored Normal file
View File

@@ -0,0 +1,63 @@
# deep-diff Change Log
**deep-diff** is a javascript/node.js module providing utility functions for determining the structural differences between objects and includes some utilities for applying differences across objects.
## Log
`1.0.2` - 2018-08-10
* Support for react-native environment - Thanks @xanderberkein
`1.0.0` - 2018-04-18
* reverted to [UMD style module](https://github.com/umdjs/umd) rather than the ES6 style, which evidently, broke lots of people's previously working code.
* fixed some bugs... see `examples/issue-XXx.js` for each issue I believe is fixed in this version.
* Closed:
* [#63 diff of equal objects should return empty array](https://github.com/flitbit/diff/issues/63)
* [#115 Remove second argument of applyChange from public api](https://github.com/flitbit/diff/issues/115)
* Resolved:
* [#78 FeatureRequest: change the diff of array elements (or add such an option)](https://github.com/flitbit/diff/issues/78)
* Fixed:
* [#47 Deleting Array elements](https://github.com/flitbit/diff/issues/47)
* [#111 Crash when comparing two undefined](https://github.com/flitbit/diff/issues/111)
`0.3.8` - 2017-05-03
* reconciled recently introduced difference between `index.es.js` and `index.js`
* improved npm commands for more reliable contributions
* added a few notes to README regarding contributing.
`0.3.7` - 2017-05-01
* fixed issue #98 by merging @sberan's pull request #99 — better handling of property with `undefined` value existing on either operand. Unit tests supplied.
`0.3.6` - 2017-04-25 — Fixed, closed lingering issues:
* fixed #74 — comparing objects with longer cycles
* fixed #70 — was not properly detecting a deletion when a property on the operand (lhs) had a value of `undefined` and was _undefined_ on the comparand (rhs). :o).
* WARNING! [Still broken when importing in Typescript](https://github.com/flitbit/diff/issues/97).
`0.3.5` - 2017-04-23 — Rolled up recent fixes; patches:
* @stevemao — #79, #80: now testing latest version of node4
* @mortonfox — #85: referencing mocha's new home
* @tdebarochez — #90: fixed error when .toString not a function
* @thiamsantos — #92, #93: changed module system for improved es2015 modules. WARNING! [This PR broke importing `deep-diff` in Typescript as reported by @kgentes in #97](https://github.com/flitbit/diff/issues/97)
`0.3.4` - Typescript users, reference this version until #97 is fixed!
`0.3.3` - Thanks @SimenB: enabled npm script for release (alternate to the Makefile). Also linting as part of `npm test`. Thanks @joeldenning: Fixed issue #35; diffs of top level arrays now working.
`0.3.3` - Thanks @SimenB: enabled npm script for release (alternate to the Makefile). Also linting as part of `npm test`. Thanks @joeldenning: Fixed issue #35; diffs of top level arrays now working.
`0.3.2` - Resolves #46; support more robust filters by including `lhs` and `rhs` in the filter callback. By @Orlando80
`0.3.1` - Better type checking by @Drinks, UMD wrapper by @SimenB. Now certifies against nodejs 12 and iojs (Thanks @SimenB).
`0.2.0` - [Fixes Bug #17](https://github.com/flitbit/diff/issues/17), [Fixes Bug #19](https://github.com/flitbit/diff/issues/19), [Enhancement #21](https://github.com/flitbit/diff/issues/21) Applying changes that are properly structured can now be applied as a change (no longer requires typeof Diff) - supports differences being applied after round-trip serialization to JSON format. Prefilter now reports the path of all changes - it was not showing a path for arrays and anything in the structure below (reported by @ravishvt).
*Breaking Change* – The structure of change records for differences below an array element has changed. Array indexes are now reported as numeric elements in the `path` if the changes is merely edited (an `E` kind). Changes of kind `A` (array) are only reported for changes in the terminal array itself and will have a nested `N` (new) item or a nested `D` (deleted) item.
`0.1.7` - [Enhancement #11](https://github.com/flitbit/diff/issues/11) Added the ability to filter properties that should not be analyzed while calculating differences. Makes `deep-diff` more usable with frameworks that attach housekeeping properties to existing objects. AngularJS does this, and the new filter ability should ease working with it.
`0.1.6` - Changed objects within nested arrays can now be applied. They were previously recording the changes appropriately but `applyDiff` would error. Comparison of `NaN` works more sanely - comparison to number shows difference, comparison to another `Nan` does not.

7
dealplustech-astro/node_modules/deep-diff/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,7 @@
Copyright (c) 2011-2018 Phillip Clark
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

239
dealplustech-astro/node_modules/deep-diff/Readme.md generated vendored Normal file
View File

@@ -0,0 +1,239 @@
# deep-diff
[![CircleCI](https://circleci.com/gh/flitbit/diff.svg?style=svg)](https://circleci.com/gh/flitbit/diff)
[![NPM](https://nodei.co/npm/deep-diff.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/deep-diff/)
**deep-diff** is a javascript/node.js module providing utility functions for determining the structural differences between objects and includes some utilities for applying differences across objects.
## Install
```bash
npm install deep-diff
```
Possible v1.0.0 incompatabilities:
* elements in arrays are now processed in reverse order, which fixes a few nagging bugs but may break some users
* If your code relied on the order in which the differences were reported then your code will break. If you consider an object graph to be a big tree, then `deep-diff` does a [pre-order traversal of the object graph](https://en.wikipedia.org/wiki/Tree_traversal), however, when it encounters an array, the array is processed from the end towards the front, with each element recursively processed in-order during further descent.
## Features
* Get the structural differences between two objects.
* Observe the structural differences between two objects.
* When structural differences represent change, apply change from one object to another.
* When structural differences represent change, selectively apply change from one object to another.
## Installation
```bash
npm install deep-diff
```
### Importing
#### nodejs
```javascript
var diff = require('deep-diff')
// or:
// const diff = require('deep-diff');
// const { diff } = require('deep-diff');
// or:
// const DeepDiff = require('deep-diff');
// const { DeepDiff } = require('deep-diff');
// es6+:
// import diff from 'deep-diff';
// import { diff } from 'deep-diff';
// es6+:
// import DeepDiff from 'deep-diff';
// import { DeepDiff } from 'deep-diff';
```
#### browser
```html
<script src="https://cdn.jsdelivr.net/npm/deep-diff@1/dist/deep-diff.min.js"></script>
```
> In a browser, `deep-diff` defines a global variable `DeepDiff`. If there is a conflict in the global namespace you can restore the conflicting definition and assign `deep-diff` to another variable like this: `var deep = DeepDiff.noConflict();`.
## Simple Examples
In order to describe differences, change revolves around an `origin` object. For consistency, the `origin` object is always the operand on the `left-hand-side` of operations. The `comparand`, which may contain changes, is always on the `right-hand-side` of operations.
``` javascript
var diff = require('deep-diff').diff;
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 = diff(lhs, rhs);
```
*v 0.2.0 and above* The code snippet above would result in the following structure describing the differences:
``` javascript
[ { kind: 'E',
path: [ 'name' ],
lhs: 'my object',
rhs: 'updated object' },
{ kind: 'E',
path: [ 'details', 'with', 2 ],
lhs: 'elements',
rhs: 'more' },
{ kind: 'A',
path: [ 'details', 'with' ],
index: 3,
item: { kind: 'N', rhs: 'elements' } },
{ kind: 'A',
path: [ 'details', 'with' ],
index: 4,
item: { kind: 'N', rhs: { than: 'before' } } } ]
```
### Differences
Differences are reported as one or more change records. Change records have the following structure:
* `kind` - indicates the kind of change; will be one of the following:
* `N` - indicates a newly added property/element
* `D` - indicates a property/element was deleted
* `E` - indicates a property/element was edited
* `A` - indicates a change occurred within an array
* `path` - the property path (from the left-hand-side root)
* `lhs` - the value on the left-hand-side of the comparison (undefined if kind === 'N')
* `rhs` - the value on the right-hand-side of the comparison (undefined if kind === 'D')
* `index` - when kind === 'A', indicates the array index where the change occurred
* `item` - when kind === 'A', contains a nested change record indicating the change that occurred at the array index
Change records are generated for all structural differences between `origin` and `comparand`. The methods only consider an object's own properties and array elements; those inherited from an object's prototype chain are not considered.
Changes to arrays are recorded simplistically. We care most about the shape of the structure; therefore we don't take the time to determine if an object moved from one slot in the array to another. Instead, we only record the structural
differences. If the structural differences are applied from the `comparand` to the `origin` then the two objects will compare as "deep equal" using most `isEqual` implementations such as found in [lodash](https://github.com/bestiejs/lodash) or [underscore](http://underscorejs.org/).
### Changes
When two objects differ, you can observe the differences as they are calculated and selectively apply those changes to the origin object (left-hand-side).
``` javascript
var observableDiff = require('deep-diff').observableDiff;
var applyChange = require('deep-diff').applyChange;
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' }]
};
observableDiff(lhs, rhs, function (d) {
// Apply all changes except to the name property...
if (d.path[d.path.length - 1] !== 'name') {
applyChange(lhs, rhs, d);
}
});
```
## API Documentation
A standard import of `var diff = require('deep-diff')` is assumed in all of the code examples. The import results in an object having the following public properties:
* `diff(lhs, rhs, prefilter, acc)` &mdash; calculates the differences between two objects, optionally prefiltering elements for comparison, and optionally using the specified accumulator.
* `observableDiff(lhs, rhs, observer, prefilter)` &mdash; calculates the differences between two objects and reports each to an observer function, optionally, prefiltering elements for comparison.
* `applyDiff(target, source, filter)` &mdash; applies any structural differences from a source object to a target object, optionally filtering each difference.
* `applyChange(target, source, change)` &mdash; applies a single change record to a target object. NOTE: `source` is unused and may be removed.
* `revertChange(target, source, change)` reverts a single change record to a target object. NOTE: `source` is unused and may be removed.
### `diff`
The `diff` function calculates the difference between two objects.
#### Arguments
* `lhs` - the left-hand operand; the origin object.
* `rhs` - the right-hand operand; the object being compared structurally with the origin object.
* `prefilter` - an optional function that determines whether difference analysis should continue down the object graph.
* `acc` - an optional accumulator/array (requirement is that it have a `push` function). Each difference is pushed to the specified accumulator.
Returns either an array of changes or, if there are no changes, `undefined`. This was originally chosen so the result would be pass a truthy test:
```javascript
var changes = diff(obja, objb);
if (changes) {
// do something with the changes.
}
```
#### Pre-filtering Object Properties
The `prefilter`'s signature should be `function(path, key)` and it should return a truthy value for any `path`-`key` combination that should be filtered. If filtered, the difference analysis does no further analysis of on the identified object-property path.
```javascript
const diff = require('deep-diff');
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');
```
## Contributing
When contributing, keep in mind that it is an objective of `deep-diff` to have no package dependencies. This may change in the future, but for now, no-dependencies.
Please run the unit tests before submitting your PR: `npm test`. Hopefully your PR includes additional unit tests to illustrate your change/modification!
When you run `npm test`, linting will be performed and any linting errors will fail the tests... this includes code formatting.
> Thanks to all those who have contributed so far!

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View 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;
}
}
}

View 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);

View 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);

View 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');
}

View 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);

View 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));

View File

@@ -0,0 +1,6 @@
var diff = require('../');
var differences = diff(undefined, undefined);
// eslint-disable-next-line no-console
console.log(differences);

View 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));

View 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));

View 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);

View 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);

View 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);

View 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));

View 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

View 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);

View 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);

View 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...

View 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

View 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

View 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

View 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));

View 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

View File

@@ -0,0 +1,11 @@
var deepDiff = require("../");
var left = {
date: null
};
var right = {
date: null
};
console.log(deepDiff(left, right));

View 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));

View 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'));

File diff suppressed because it is too large Load Diff

526
dealplustech-astro/node_modules/deep-diff/index.js generated vendored Normal file
View File

@@ -0,0 +1,526 @@
;(function(root, factory) { // eslint-disable-line no-extra-semi
var deepDiff = factory(root);
// eslint-disable-next-line no-undef
if (typeof define === 'function' && define.amd) {
// AMD
define('DeepDiff', function() { // eslint-disable-line no-undef
return deepDiff;
});
} else if (typeof exports === 'object' || typeof navigator === 'object' && navigator.product.match(/ReactNative/i)) {
// Node.js or ReactNative
module.exports = deepDiff;
} else {
// Browser globals
var _deepdiff = root.DeepDiff;
deepDiff.noConflict = function() {
if (root.DeepDiff === deepDiff) {
root.DeepDiff = _deepdiff;
}
return deepDiff;
};
root.DeepDiff = deepDiff;
}
}(this, function(root) {
var validKinds = ['N', 'E', 'A', 'D'];
// nodejs compatible on server side and in the browser.
function inherits(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
}
function Diff(kind, path) {
Object.defineProperty(this, 'kind', {
value: kind,
enumerable: true
});
if (path && path.length) {
Object.defineProperty(this, 'path', {
value: path,
enumerable: true
});
}
}
function DiffEdit(path, origin, value) {
DiffEdit.super_.call(this, 'E', path);
Object.defineProperty(this, 'lhs', {
value: origin,
enumerable: true
});
Object.defineProperty(this, 'rhs', {
value: value,
enumerable: true
});
}
inherits(DiffEdit, Diff);
function DiffNew(path, value) {
DiffNew.super_.call(this, 'N', path);
Object.defineProperty(this, 'rhs', {
value: value,
enumerable: true
});
}
inherits(DiffNew, Diff);
function DiffDeleted(path, value) {
DiffDeleted.super_.call(this, 'D', path);
Object.defineProperty(this, 'lhs', {
value: value,
enumerable: true
});
}
inherits(DiffDeleted, Diff);
function DiffArray(path, index, item) {
DiffArray.super_.call(this, 'A', path);
Object.defineProperty(this, 'index', {
value: index,
enumerable: true
});
Object.defineProperty(this, 'item', {
value: item,
enumerable: true
});
}
inherits(DiffArray, Diff);
function arrayRemove(arr, from, to) {
var rest = arr.slice((to || from) + 1 || arr.length);
arr.length = from < 0 ? arr.length + from : from;
arr.push.apply(arr, rest);
return arr;
}
function realTypeOf(subject) {
var type = typeof subject;
if (type !== 'object') {
return type;
}
if (subject === Math) {
return 'math';
} else if (subject === null) {
return 'null';
} else if (Array.isArray(subject)) {
return 'array';
} else if (Object.prototype.toString.call(subject) === '[object Date]') {
return 'date';
} else if (typeof subject.toString === 'function' && /^\/.*\//.test(subject.toString())) {
return 'regexp';
}
return 'object';
}
// http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
function hashThisString(string) {
var hash = 0;
if (string.length === 0) { return hash; }
for (var i = 0; i < string.length; i++) {
var char = string.charCodeAt(i);
hash = ((hash << 5) - hash) + char;
hash = hash & hash; // Convert to 32bit integer
}
return hash;
}
// Gets a hash of the given object in an array order-independent fashion
// also object key order independent (easier since they can be alphabetized)
function getOrderIndependentHash(object) {
var accum = 0;
var type = realTypeOf(object);
if (type === 'array') {
object.forEach(function (item) {
// Addition is commutative so this is order indep
accum += getOrderIndependentHash(item);
});
var arrayString = '[type: array, hash: ' + accum + ']';
return accum + hashThisString(arrayString);
}
if (type === 'object') {
for (var key in object) {
if (object.hasOwnProperty(key)) {
var keyValueString = '[ type: object, key: ' + key + ', value hash: ' + getOrderIndependentHash(object[key]) + ']';
accum += hashThisString(keyValueString);
}
}
return accum;
}
// Non object, non array...should be good?
var stringToHash = '[ type: ' + type + ' ; value: ' + object + ']';
return accum + hashThisString(stringToHash);
}
function deepDiff(lhs, rhs, changes, prefilter, path, key, stack, orderIndependent) {
changes = changes || [];
path = path || [];
stack = stack || [];
var currentPath = path.slice(0);
if (typeof key !== 'undefined' && key !== null) {
if (prefilter) {
if (typeof (prefilter) === 'function' && prefilter(currentPath, key)) {
return;
} else if (typeof (prefilter) === 'object') {
if (prefilter.prefilter && prefilter.prefilter(currentPath, key)) {
return;
}
if (prefilter.normalize) {
var alt = prefilter.normalize(currentPath, key, lhs, rhs);
if (alt) {
lhs = alt[0];
rhs = alt[1];
}
}
}
}
currentPath.push(key);
}
// Use string comparison for regexes
if (realTypeOf(lhs) === 'regexp' && realTypeOf(rhs) === 'regexp') {
lhs = lhs.toString();
rhs = rhs.toString();
}
var ltype = typeof lhs;
var rtype = typeof rhs;
var i, j, k, other;
var ldefined = ltype !== 'undefined' ||
(stack && (stack.length > 0) && stack[stack.length - 1].lhs &&
Object.getOwnPropertyDescriptor(stack[stack.length - 1].lhs, key));
var rdefined = rtype !== 'undefined' ||
(stack && (stack.length > 0) && stack[stack.length - 1].rhs &&
Object.getOwnPropertyDescriptor(stack[stack.length - 1].rhs, key));
if (!ldefined && rdefined) {
changes.push(new DiffNew(currentPath, rhs));
} else if (!rdefined && ldefined) {
changes.push(new DiffDeleted(currentPath, lhs));
} else if (realTypeOf(lhs) !== realTypeOf(rhs)) {
changes.push(new DiffEdit(currentPath, lhs, rhs));
} else if (realTypeOf(lhs) === 'date' && (lhs - rhs) !== 0) {
changes.push(new DiffEdit(currentPath, lhs, rhs));
} else if (ltype === 'object' && lhs !== null && rhs !== null) {
for (i = stack.length - 1; i > -1; --i) {
if (stack[i].lhs === lhs) {
other = true;
break;
}
}
if (!other) {
stack.push({ lhs: lhs, rhs: rhs });
if (Array.isArray(lhs)) {
// If order doesn't matter, we need to sort our arrays
if (orderIndependent) {
lhs.sort(function (a, b) {
return getOrderIndependentHash(a) - getOrderIndependentHash(b);
});
rhs.sort(function (a, b) {
return getOrderIndependentHash(a) - getOrderIndependentHash(b);
});
}
i = rhs.length - 1;
j = lhs.length - 1;
while (i > j) {
changes.push(new DiffArray(currentPath, i, new DiffNew(undefined, rhs[i--])));
}
while (j > i) {
changes.push(new DiffArray(currentPath, j, new DiffDeleted(undefined, lhs[j--])));
}
for (; i >= 0; --i) {
deepDiff(lhs[i], rhs[i], changes, prefilter, currentPath, i, stack, orderIndependent);
}
} else {
var akeys = Object.keys(lhs);
var pkeys = Object.keys(rhs);
for (i = 0; i < akeys.length; ++i) {
k = akeys[i];
other = pkeys.indexOf(k);
if (other >= 0) {
deepDiff(lhs[k], rhs[k], changes, prefilter, currentPath, k, stack, orderIndependent);
pkeys[other] = null;
} else {
deepDiff(lhs[k], undefined, changes, prefilter, currentPath, k, stack, orderIndependent);
}
}
for (i = 0; i < pkeys.length; ++i) {
k = pkeys[i];
if (k) {
deepDiff(undefined, rhs[k], changes, prefilter, currentPath, k, stack, orderIndependent);
}
}
}
stack.length = stack.length - 1;
} else if (lhs !== rhs) {
// lhs is contains a cycle at this element and it differs from rhs
changes.push(new DiffEdit(currentPath, lhs, rhs));
}
} else if (lhs !== rhs) {
if (!(ltype === 'number' && isNaN(lhs) && isNaN(rhs))) {
changes.push(new DiffEdit(currentPath, lhs, rhs));
}
}
}
function observableDiff(lhs, rhs, observer, prefilter, orderIndependent) {
var changes = [];
deepDiff(lhs, rhs, changes, prefilter, null, null, null, orderIndependent);
if (observer) {
for (var i = 0; i < changes.length; ++i) {
observer(changes[i]);
}
}
return changes;
}
function orderIndependentDeepDiff(lhs, rhs, changes, prefilter, path, key, stack) {
return deepDiff(lhs, rhs, changes, prefilter, path, key, stack, true);
}
function accumulateDiff(lhs, rhs, prefilter, accum) {
var observer = (accum) ?
function (difference) {
if (difference) {
accum.push(difference);
}
} : undefined;
var changes = observableDiff(lhs, rhs, observer, prefilter);
return (accum) ? accum : (changes.length) ? changes : undefined;
}
function accumulateOrderIndependentDiff(lhs, rhs, prefilter, accum) {
var observer = (accum) ?
function (difference) {
if (difference) {
accum.push(difference);
}
} : undefined;
var changes = observableDiff(lhs, rhs, observer, prefilter, true);
return (accum) ? accum : (changes.length) ? changes : undefined;
}
function applyArrayChange(arr, index, change) {
if (change.path && change.path.length) {
var it = arr[index],
i, u = change.path.length - 1;
for (i = 0; i < u; i++) {
it = it[change.path[i]];
}
switch (change.kind) {
case 'A':
applyArrayChange(it[change.path[i]], change.index, change.item);
break;
case 'D':
delete it[change.path[i]];
break;
case 'E':
case 'N':
it[change.path[i]] = change.rhs;
break;
}
} else {
switch (change.kind) {
case 'A':
applyArrayChange(arr[index], change.index, change.item);
break;
case 'D':
arr = arrayRemove(arr, index);
break;
case 'E':
case 'N':
arr[index] = change.rhs;
break;
}
}
return arr;
}
function applyChange(target, source, change) {
if (typeof change === 'undefined' && source && ~validKinds.indexOf(source.kind)) {
change = source;
}
if (target && change && change.kind) {
var it = target,
i = -1,
last = change.path ? change.path.length - 1 : 0;
while (++i < last) {
if (typeof it[change.path[i]] === 'undefined') {
it[change.path[i]] = (typeof change.path[i + 1] !== 'undefined' && typeof change.path[i + 1] === 'number') ? [] : {};
}
it = it[change.path[i]];
}
switch (change.kind) {
case 'A':
if (change.path && typeof it[change.path[i]] === 'undefined') {
it[change.path[i]] = [];
}
applyArrayChange(change.path ? it[change.path[i]] : it, change.index, change.item);
break;
case 'D':
delete it[change.path[i]];
break;
case 'E':
case 'N':
it[change.path[i]] = change.rhs;
break;
}
}
}
function revertArrayChange(arr, index, change) {
if (change.path && change.path.length) {
// the structure of the object at the index has changed...
var it = arr[index],
i, u = change.path.length - 1;
for (i = 0; i < u; i++) {
it = it[change.path[i]];
}
switch (change.kind) {
case 'A':
revertArrayChange(it[change.path[i]], change.index, change.item);
break;
case 'D':
it[change.path[i]] = change.lhs;
break;
case 'E':
it[change.path[i]] = change.lhs;
break;
case 'N':
delete it[change.path[i]];
break;
}
} else {
// the array item is different...
switch (change.kind) {
case 'A':
revertArrayChange(arr[index], change.index, change.item);
break;
case 'D':
arr[index] = change.lhs;
break;
case 'E':
arr[index] = change.lhs;
break;
case 'N':
arr = arrayRemove(arr, index);
break;
}
}
return arr;
}
function revertChange(target, source, change) {
if (target && source && change && change.kind) {
var it = target,
i, u;
u = change.path.length - 1;
for (i = 0; i < u; i++) {
if (typeof it[change.path[i]] === 'undefined') {
it[change.path[i]] = {};
}
it = it[change.path[i]];
}
switch (change.kind) {
case 'A':
// Array was modified...
// it will be an array...
revertArrayChange(it[change.path[i]], change.index, change.item);
break;
case 'D':
// Item was deleted...
it[change.path[i]] = change.lhs;
break;
case 'E':
// Item was edited...
it[change.path[i]] = change.lhs;
break;
case 'N':
// Item is new...
delete it[change.path[i]];
break;
}
}
}
function applyDiff(target, source, filter) {
if (target && source) {
var onChange = function (change) {
if (!filter || filter(target, source, change)) {
applyChange(target, source, change);
}
};
observableDiff(target, source, onChange);
}
}
Object.defineProperties(accumulateDiff, {
diff: {
value: accumulateDiff,
enumerable: true
},
orderIndependentDiff: {
value: accumulateOrderIndependentDiff,
enumerable: true
},
observableDiff: {
value: observableDiff,
enumerable: true
},
orderIndependentObservableDiff: {
value: orderIndependentDeepDiff,
enumerable: true
},
orderIndepHash: {
value: getOrderIndependentHash,
enumerable: true
},
applyDiff: {
value: applyDiff,
enumerable: true
},
applyChange: {
value: applyChange,
enumerable: true
},
revertChange: {
value: revertChange,
enumerable: true
},
isConflict: {
value: function () {
return typeof $conflict !== 'undefined';
},
enumerable: true
}
});
// hackish...
accumulateDiff.DeepDiff = accumulateDiff;
// ...but works with:
// import DeepDiff from 'deep-diff'
// import { DeepDiff } from 'deep-diff'
// const DeepDiff = require('deep-diff');
// const { DeepDiff } = require('deep-diff');
if (root) {
root.DeepDiff = accumulateDiff;
}
return accumulateDiff;
}));

74
dealplustech-astro/node_modules/deep-diff/package.json generated vendored Normal file
View File

@@ -0,0 +1,74 @@
{
"name": "deep-diff",
"description": "Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.",
"version": "1.0.2",
"license": "MIT",
"keywords": [
"diff",
"difference",
"compare",
"change-tracking"
],
"author": "Phillip Clark <phillip@flitbit.com>",
"contributors": [
"Simen Bekkhus <sbekkhus91@gmail.com>",
"Paul Pflugradt <paulpflugradt@googlemail.com>",
"wooorm <tituswormer@gmail.com>",
"Nicholas Calugar <njcalugar@gmail.com>",
"Yandell <hyandell@amazon.com>",
"Thiago Santos <thia.mdossantos@gmail.com>",
"Steve Mao <maochenyan@gmail.com>",
"Mats Bryntse <mats.dev@bryntum.com>",
"Phillip Clark <pclark@leisurelink.com>",
"ZauberNerd <zaubernerd@zaubernerd.de>",
"ravishivt <javishi@gmail.com>",
"Daniel Spangler <daniel.spangler@gmail.com>",
"Sam Beran <sberan@gmail.com>",
"Thomas de Barochez <thomas.barochez+github@gmail.com>",
"Morton Fox <github@qslw.com>",
"Amila Welihinda <amilajack@users.noreply.github.com>",
"Will Biddy <willbiddy@gmail.com>",
"icesoar <icesoar@hotmail.com>",
"Serkan Serttop <serkanserttop@yahoo.com>",
"orlando <operri@opentable.com>",
"Tom MacWright <tmcw@users.noreply.github.com>",
"Denning <denningj@amazon.com>",
"Dan Drinkard <dan.drinkard@gmail.com>",
"Elad Efrat <elad@iNNU.ORG>",
"caasi Huang <caasi.igd@gmail.com>",
"Tom Ashworth <tashworth@twitter.com>"
],
"repository": {
"type": "git",
"url": "git://github.com/flitbit/diff.git"
},
"main": "./index.js",
"scripts": {
"prerelease": "npm run clean && npm run test",
"release": "uglifyjs -c -m -o dist/deep-diff.min.js --source-map -r '$,require,exports,self,module,define,navigator' index.js",
"clean": "rimraf dist && mkdir dist",
"preversion": "npm run release",
"postversion": "git push && git push --tags",
"pretest": "npm run lint",
"test": "mocha test/**/*.js",
"test:watch": "nodemon --ext js,json --ignore dist/ --exec 'npm test'",
"preci": "npm run lint",
"ci": "mocha --reporter mocha-junit-reporter test/**/*.js",
"lint": "eslint index.js test"
},
"devDependencies": {
"bluebird": "^3.5.1",
"deep-equal": "^1.0.1",
"eslint": "^4.19.1",
"eslint-plugin-mocha": "^5.0.0",
"expect.js": "^0.3.1",
"json": "^9.0.6",
"json-ptr": "^1.1.0",
"lodash": "^4.17.10",
"mocha": "^5.1.1",
"mocha-junit-reporter": "^1.17.0",
"nodemon": "^1.17.4",
"rimraf": "^2.6.2",
"uglify-js": "^3.3.25"
}
}

View File

@@ -0,0 +1,10 @@
{
"plugins": [
"mocha"
],
"env": {
"node": true,
"mocha": true,
"browser": true
},
}

View File

@@ -0,0 +1,34 @@
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link href="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.css" rel="stylesheet" />
</head>
<body>
<!-- You should open this file directly in a browser from your file system, not from a server... -->
<div id="mocha"></div>
<script>
globalConflict = "This is a conflict";
DeepDiff = globalConflict;
</script>
<script src="https://cdn.rawgit.com/jquery/jquery/2.1.4/dist/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/Automattic/expect.js/0.3.1/index.js"></script>
<script src="https://cdn.rawgit.com/mochajs/mocha/2.2.5/mocha.js"></script>
<script>
mocha.setup('bdd')
</script>
<!--script src="../index.js"></script-->
<script src="../dist/deep-diff.min.js"></script>
<script src="tests.js"></script>
<script>
window.onload = function () {
mocha.checkLeaks();
mocha.globals(['jQuery']);
mocha.run();
};
</script>
</body>
</html>

759
dealplustech-astro/node_modules/deep-diff/test/tests.js generated vendored Normal file
View File

@@ -0,0 +1,759 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) { // eslint-disable-line no-undef
define(['deep-diff', 'expect.js'], factory);// eslint-disable-line no-undef
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require('../'), require('expect.js'));
} else {
root.returnExports = factory(root.DeepDiff, root.expect);
}
// eslint-disable-next-line no-undef
}(typeof self !== 'undefined' ? self : this, function (deep, expect) {
describe('deep-diff', function () {
var empty = {};
describe('A target that has no properties', function () {
it('shows no differences when compared to another empty object', function () {
expect(deep.diff(empty, {})).to.be.an('undefined');
});
describe('when compared to a different type of keyless object', function () {
var comparandTuples = [
['an array', {
key: []
}],
['an object', {
key: {}
}],
['a date', {
key: new Date()
}],
['a null', {
key: null
}],
['a regexp literal', {
key: /a/
}],
['Math', {
key: Math
}]
];
comparandTuples.forEach(function (lhsTuple) {
comparandTuples.forEach(function (rhsTuple) {
if (lhsTuple[0] === rhsTuple[0]) {
return;
}
it('shows differences when comparing ' + lhsTuple[0] + ' to ' + rhsTuple[0], function () {
var diff = deep.diff(lhsTuple[1], rhsTuple[1]);
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('E');
});
});
});
});
describe('when compared with an object having other properties', function () {
var comparand = {
other: 'property',
another: 13.13
};
var diff = deep.diff(empty, comparand);
it('the differences are reported', function () {
expect(diff).to.be.ok();
expect(diff.length).to.be(2);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('N');
expect(diff[0]).to.have.property('path');
expect(diff[0].path).to.be.an(Array);
expect(diff[0].path[0]).to.eql('other');
expect(diff[0]).to.have.property('rhs');
expect(diff[0].rhs).to.be('property');
expect(diff[1]).to.have.property('kind');
expect(diff[1].kind).to.be('N');
expect(diff[1]).to.have.property('path');
expect(diff[1].path).to.be.an(Array);
expect(diff[1].path[0]).to.eql('another');
expect(diff[1]).to.have.property('rhs');
expect(diff[1].rhs).to.be(13.13);
});
});
});
describe('A target that has one property', function () {
var lhs = {
one: 'property'
};
it('shows no differences when compared to itself', function () {
expect(deep.diff(lhs, lhs)).to.be.an('undefined');
});
it('shows the property as removed when compared to an empty object', function () {
var diff = deep.diff(lhs, empty);
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('D');
});
it('shows the property as edited when compared to an object with null', function () {
var diff = deep.diff(lhs, {
one: null
});
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('E');
});
it('shows the property as edited when compared to an array', function () {
var diff = deep.diff(lhs, ['one']);
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('E');
});
});
describe('A target that has null value', function () {
var lhs = {
key: null
};
it('shows no differences when compared to itself', function () {
expect(deep.diff(lhs, lhs)).to.be.an('undefined');
});
it('shows the property as removed when compared to an empty object', function () {
var diff = deep.diff(lhs, empty);
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('D');
});
it('shows the property is changed when compared to an object that has value', function () {
var diff = deep.diff(lhs, {
key: 'value'
});
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('E');
});
it('shows that an object property is changed when it is set to null', function () {
lhs.key = {
nested: 'value'
};
var diff = deep.diff(lhs, {
key: null
});
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('E');
});
});
describe('A target that has a date value', function () {
var lhs = {
key: new Date(555555555555)
};
it('shows the property is changed with a new date value', function () {
var diff = deep.diff(lhs, {
key: new Date(777777777777)
});
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('E');
});
});
describe('A target that has a NaN', function () {
var lhs = {
key: NaN
};
it('shows the property is changed when compared to another number', function () {
var diff = deep.diff(lhs, {
key: 0
});
expect(diff).to.be.ok();
expect(diff.length).to.be(1);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('E');
});
it('shows no differences when compared to another NaN', function () {
var diff = deep.diff(lhs, {
key: NaN
});
expect(diff).to.be.an('undefined');
});
});
describe('can revert namespace using noConflict', function () {
if (deep.noConflict) {
deep = deep.noConflict();
it('conflict is restored (when applicable)', function () {
// In node there is no global conflict.
if (typeof globalConflict !== 'undefined') {
expect(DeepDiff).to.be(deep); // eslint-disable-line no-undef
}
});
it('DeepDiff functionality available through result of noConflict()', function () {
expect(deep.applyDiff).to.be.a('function');
});
}
});
describe('When filtering keys', function () {
var lhs = {
enhancement: 'Filter/Ignore Keys?',
numero: 11,
submittedBy: 'ericclemmons',
supportedBy: ['ericclemmons'],
status: 'open'
};
var rhs = {
enhancement: 'Filter/Ignore Keys?',
numero: 11,
submittedBy: 'ericclemmons',
supportedBy: [
'ericclemmons',
'TylerGarlick',
'flitbit',
'ergdev'
],
status: 'closed',
fixedBy: 'flitbit'
};
describe('if the filtered property is an array', function () {
it('changes to the array do not appear as a difference', function () {
var prefilter = function (path, key) {
return key === 'supportedBy';
};
var diff = deep(lhs, rhs, prefilter);
expect(diff).to.be.ok();
expect(diff.length).to.be(2);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('E');
expect(diff[1]).to.have.property('kind');
expect(diff[1].kind).to.be('N');
});
});
describe('if the filtered property is not an array', function () {
it('changes do not appear as a difference', function () {
var prefilter = function (path, key) {
return key === 'fixedBy';
};
var diff = deep(lhs, rhs, prefilter);
expect(diff).to.be.ok();
expect(diff.length).to.be(4);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('A');
expect(diff[1]).to.have.property('kind');
expect(diff[1].kind).to.be('A');
expect(diff[2]).to.have.property('kind');
expect(diff[2].kind).to.be('A');
expect(diff[3]).to.have.property('kind');
expect(diff[3].kind).to.be('E');
});
});
});
describe('A target that has nested values', function () {
var nestedOne = {
noChange: 'same',
levelOne: {
levelTwo: 'value'
},
arrayOne: [{
objValue: 'value'
}]
};
var nestedTwo = {
noChange: 'same',
levelOne: {
levelTwo: 'another value'
},
arrayOne: [{
objValue: 'new value'
}, {
objValue: 'more value'
}]
};
it('shows no differences when compared to itself', function () {
expect(deep.diff(nestedOne, nestedOne)).to.be.an('undefined');
});
it('shows the property as removed when compared to an empty object', function () {
var diff = deep(nestedOne, empty);
expect(diff).to.be.ok();
expect(diff.length).to.be(3);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('D');
expect(diff[1]).to.have.property('kind');
expect(diff[1].kind).to.be('D');
});
it('shows the property is changed when compared to an object that has value', function () {
var diff = deep.diff(nestedOne, nestedTwo);
expect(diff).to.be.ok();
expect(diff.length).to.be(3);
});
it('shows the property as added when compared to an empty object on left', function () {
var diff = deep.diff(empty, nestedOne);
expect(diff).to.be.ok();
expect(diff.length).to.be(3);
expect(diff[0]).to.have.property('kind');
expect(diff[0].kind).to.be('N');
});
describe('when diff is applied to a different empty object', function () {
var diff = deep.diff(nestedOne, nestedTwo);
it('has result with nested values', function () {
var result = {};
deep.applyChange(result, nestedTwo, diff[0]);
expect(result.levelOne).to.be.ok();
expect(result.levelOne).to.be.an('object');
expect(result.levelOne.levelTwo).to.be.ok();
expect(result.levelOne.levelTwo).to.eql('another value');
});
it('has result with array object values', function () {
var result = {};
deep.applyChange(result, nestedTwo, diff[2]);
expect(result.arrayOne).to.be.ok();
expect(result.arrayOne).to.be.an('array');
expect(result.arrayOne[0]).to.be.ok();
expect(result.arrayOne[0].objValue).to.be.ok();
expect(result.arrayOne[0].objValue).to.equal('new value');
});
it('has result with added array objects', function () {
var result = {};
deep.applyChange(result, nestedTwo, diff[1]);
expect(result.arrayOne).to.be.ok();
expect(result.arrayOne).to.be.an('array');
expect(result.arrayOne[1]).to.be.ok();
expect(result.arrayOne[1].objValue).to.be.ok();
expect(result.arrayOne[1].objValue).to.equal('more value');
});
});
});
describe('regression test for bug #10, ', function () {
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'
}]
}]
};
describe('differences in nested arrays are detected', function () {
var diff = deep.diff(lhs, rhs);
// there should be differences
expect(diff).to.be.ok();
expect(diff.length).to.be(6);
it('differences can be applied', function () {
var applied = deep.applyDiff(lhs, rhs);
it('and the result equals the rhs', function () {
expect(applied).to.eql(rhs);
});
});
});
});
describe('regression test for bug #35', function () {
var lhs = ['a', 'a', 'a'];
var rhs = ['a'];
it('can apply diffs between two top level arrays', function () {
var differences = deep.diff(lhs, rhs);
differences.forEach(function (it) {
deep.applyChange(lhs, true, it);
});
expect(lhs).to.eql(['a']);
});
});
describe('Objects from different frames', function () {
if (typeof globalConflict === 'undefined') { return; }
// eslint-disable-next-line no-undef
var frame = document.createElement('iframe');
// eslint-disable-next-line no-undef
document.body.appendChild(frame);
var lhs = new frame.contentWindow.Date(2010, 1, 1);
var rhs = new frame.contentWindow.Date(2010, 1, 1);
it('can compare date instances from a different frame', function () {
var differences = deep.diff(lhs, rhs);
expect(differences).to.be(undefined);
});
});
describe('Comparing regexes should work', function () {
var lhs = /foo/;
var rhs = /foo/i;
it('can compare regex instances', function () {
var diff = deep.diff(lhs, rhs);
expect(diff.length).to.be(1);
expect(diff[0].kind).to.be('E');
expect(diff[0].path).to.not.be.ok();
expect(diff[0].lhs).to.be('/foo/');
expect(diff[0].rhs).to.be('/foo/i');
});
});
describe('subject.toString is not a function', function () {
var lhs = {
left: 'yes',
right: 'no',
};
var rhs = {
left: {
toString: true,
},
right: 'no',
};
it('should not throw a TypeError', function () {
var diff = deep.diff(lhs, rhs);
expect(diff.length).to.be(1);
});
});
describe('regression test for issue #83', function () {
var lhs = {
date: null
};
var rhs = {
date: null
};
it('should not detect a difference', function () {
expect(deep.diff(lhs, rhs)).to.be(undefined);
});
});
describe('regression test for issue #70', function () {
it('should detect a difference with undefined property on lhs', function () {
var diff = deep.diff({ foo: undefined }, {});
expect(diff).to.be.an(Array);
expect(diff.length).to.be(1);
expect(diff[0].kind).to.be('D');
expect(diff[0].path).to.be.an('array');
expect(diff[0].path).to.have.length(1);
expect(diff[0].path[0]).to.be('foo');
expect(diff[0].lhs).to.be(undefined);
});
it('should detect a difference with undefined property on rhs', function () {
var diff = deep.diff({}, { foo: undefined });
expect(diff).to.be.an(Array);
expect(diff.length).to.be(1);
expect(diff[0].kind).to.be('N');
expect(diff[0].path).to.be.an('array');
expect(diff[0].path).to.have.length(1);
expect(diff[0].path[0]).to.be('foo');
expect(diff[0].rhs).to.be(undefined);
});
});
describe('regression test for issue #98', function () {
var lhs = { foo: undefined };
var rhs = { foo: undefined };
it('should not detect a difference with two undefined property values', function () {
var diff = deep.diff(lhs, rhs);
expect(diff).to.be(undefined);
});
});
describe('regression tests for issue #102', function () {
it('should not throw a TypeError', function () {
var diff = deep.diff(null, undefined);
expect(diff).to.be.an(Array);
expect(diff.length).to.be(1);
expect(diff[0].kind).to.be('D');
expect(diff[0].lhs).to.be(null);
});
it('should not throw a TypeError', function () {
var diff = deep.diff(Object.create(null), { foo: undefined });
expect(diff).to.be.an(Array);
expect(diff.length).to.be(1);
expect(diff[0].kind).to.be('N');
expect(diff[0].rhs).to.be(undefined);
});
});
describe('Order independent hash testing', function () {
function sameHash(a, b) {
expect(deep.orderIndepHash(a)).to.equal(deep.orderIndepHash(b));
}
function differentHash(a, b) {
expect(deep.orderIndepHash(a)).to.not.equal(deep.orderIndepHash(b));
}
describe('Order indepdendent hash function should give different values for different objects', function () {
it('should give different values for different "simple" types', function () {
differentHash(1, -20);
differentHash('foo', 45);
differentHash('pie', 'something else');
differentHash(1.3332, 1);
differentHash(1, null);
differentHash('this is kind of a long string, don\'t you think?', 'the quick brown fox jumped over the lazy doge');
differentHash(true, 2);
differentHash(false, 'flooog');
});
it('should give different values for string and object with string', function () {
differentHash('some string', { key: 'some string' });
});
it('should give different values for number and array', function () {
differentHash(1, [1]);
});
it('should give different values for string and array of string', function () {
differentHash('string', ['string']);
});
it('should give different values for boolean and object with boolean', function () {
differentHash(true, { key: true });
});
it('should give different values for different arrays', function () {
differentHash([1, 2, 3], [1, 2]);
differentHash([1, 4, 5, 6], ['foo', 1, true, undefined]);
differentHash([1, 4, 6], [1, 4, 7]);
differentHash([1, 3, 5], ['1', '3', '5']);
});
it('should give different values for different objects', function () {
differentHash({ key: 'value' }, { other: 'value' });
differentHash({ a: { b: 'c' } }, { a: 'b' });
});
it('should differentiate between arrays and objects', function () {
differentHash([1, true, '1'], { a: 1, b: true, c: '1' });
});
});
describe('Order independent hash function should work in pathological cases', function () {
it('should work in funky javascript cases', function () {
differentHash(undefined, null);
differentHash(0, undefined);
differentHash(0, null);
differentHash(0, false);
differentHash(0, []);
differentHash('', []);
differentHash(3.22, '3.22');
differentHash(true, 'true');
differentHash(false, 0);
});
it('should work on empty array and object', function () {
differentHash([], {});
});
it('should work on empty object and undefined', function () {
differentHash({}, undefined);
});
it('should work on empty array and array with 0', function () {
differentHash([], [0]);
});
});
describe('Order independent hash function should be order independent', function () {
it('should not care about array order', function () {
sameHash([1, 2, 3], [3, 2, 1]);
sameHash(['hi', true, 9.4], [true, 'hi', 9.4]);
});
it('should not care about key order in an object', function () {
sameHash({ foo: 'bar', foz: 'baz' }, { foz: 'baz', foo: 'bar' });
});
it('should work with complicated objects', function () {
var obj1 = {
foo: 'bar',
faz: [
1,
'pie',
{
food: 'yum'
}
]
};
var obj2 = {
faz: [
'pie',
{
food: 'yum'
},
1
],
foo: 'bar'
};
sameHash(obj1, obj2);
});
});
});
describe('Order indepedent array comparison should work', function () {
it('can compare simple arrays in an order independent fashion', function () {
var lhs = [1, 2, 3];
var rhs = [1, 3, 2];
var diff = deep.orderIndependentDiff(lhs, rhs);
expect(diff).to.be(undefined);
});
it('still works with repeated elements', function () {
var lhs = [1, 1, 2];
var rhs = [1, 2, 1];
var diff = deep.orderIndependentDiff(lhs, rhs);
expect(diff).to.be(undefined);
});
it('works on complex objects', function () {
var obj1 = {
foo: 'bar',
faz: [
1,
'pie',
{
food: 'yum'
}
]
};
var obj2 = {
faz: [
'pie',
{
food: 'yum'
},
1
],
foo: 'bar'
};
var diff = deep.orderIndependentDiff(obj1, obj2);
expect(diff).to.be(undefined);
});
it('should report some difference in non-equal arrays', function () {
var lhs = [1, 2, 3];
var rhs = [2, 2, 3];
var diff = deep.orderIndependentDiff(lhs, rhs);
expect(diff.length).to.be.ok();
});
});
});
}));