Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert typescript to 2.2.0, #235

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,6 +10,7 @@ npm-debug.log

# Typescript
*.d.ts
test/spec/typings/typingsSpec.js

# compiled files
src/*.js
Expand Down
70 changes: 51 additions & 19 deletions dist/fast-json-patch.js
Expand Up @@ -96,19 +96,15 @@ var jsonpatch =
* MIT license
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var _hasOwnProperty = Object.prototype.hasOwnProperty;
function hasOwnProperty(obj, key) {
return _hasOwnProperty.call(obj, key);
Expand Down Expand Up @@ -255,7 +251,7 @@ function patchErrorMessageFormatter(message, args) {
}
return messageParts.join('\n');
}
var PatchError = /** @class */ (function (_super) {
var PatchError = (function (_super) {
__extends(PatchError, _super);
function PatchError(message, name, index, operation, tree) {
var _newTarget = this.constructor;
Expand All @@ -277,7 +273,6 @@ exports.PatchError = PatchError;
/* 1 */
/***/ (function(module, exports, __webpack_require__) {

Object.defineProperty(exports, "__esModule", { value: true });
var areEquals = __webpack_require__(3);
var helpers_1 = __webpack_require__(0);
exports.JsonPatchError = helpers_1.PatchError;
Expand Down Expand Up @@ -336,7 +331,7 @@ var arrOps = {
if (helpers_1.isInteger(i)) {
arr.splice(i, 0, this.value);
}
else { // array props
else {
arr[i] = this.value;
}
// this may be needed when using '-' in an array
Expand Down Expand Up @@ -412,9 +407,9 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
returnValue.removed = document; //document we removed
return returnValue;
}
else if (operation.op === 'move' || operation.op === 'copy') { // it's a move or copy to root
else if (operation.op === 'move' || operation.op === 'copy') {
returnValue.newDocument = getValueByPointer(document, operation.from); // get the value by json-pointer in `from` field
if (operation.op === 'move') { // report removed item
if (operation.op === 'move') {
returnValue.removed = document;
}
return returnValue;
Expand All @@ -427,7 +422,7 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
returnValue.newDocument = document;
return returnValue;
}
else if (operation.op === 'remove') { // a remove on root
else if (operation.op === 'remove') {
returnValue.removed = document;
returnValue.newDocument = null;
return returnValue;
Expand All @@ -436,7 +431,7 @@ function applyOperation(document, operation, validateOperation, mutateDocument,
operation.value = document;
return returnValue;
}
else { /* bad operation */
else {
if (validateOperation) {
throw new exports.JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document);
}
Expand Down Expand Up @@ -568,7 +563,7 @@ exports.applyPatch = applyPatch;
*/
function applyReducer(document, operation, index) {
var operationResult = applyOperation(document, operation);
if (operationResult.test === false) { // failed test
if (operationResult.test === false) {
throw new exports.JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document);
}
return operationResult.newDocument;
Expand Down Expand Up @@ -660,13 +655,34 @@ function validate(sequence, document, externalValidator) {
}
}
exports.validate = validate;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Default export for backwards compat
*/
exports.default = {
JsonPatchError: exports.JsonPatchError,
deepClone: exports.deepClone,
getValueByPointer: getValueByPointer,
applyOperation: applyOperation,
applyPatch: applyPatch,
applyReducer: applyReducer,
validator: validator,
validate: validate
};


/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {

Object.defineProperty(exports, "__esModule", { value: true });
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
/*!
* https://github.com/Starcounter-Jack/JSON-Patch
* (c) 2017 Joachim Wester
Expand All @@ -689,14 +705,14 @@ exports.deepClone = helpers_2._deepClone;
exports.escapePathComponent = helpers_2.escapePathComponent;
exports.unescapePathComponent = helpers_2.unescapePathComponent;
var beforeDict = new WeakMap();
var Mirror = /** @class */ (function () {
var Mirror = (function () {
function Mirror(obj) {
this.observers = new Map();
this.obj = obj;
}
return Mirror;
}());
var ObserverInfo = /** @class */ (function () {
var ObserverInfo = (function () {
function ObserverInfo(callback, observer) {
this.callback = callback;
this.observer = observer;
Expand Down Expand Up @@ -749,7 +765,7 @@ function observe(obj, callback) {
clearTimeout(observer.next);
observer.next = setTimeout(dirtyCheck);
};
if (typeof window !== 'undefined') { //not Node
if (typeof window !== 'undefined') {
window.addEventListener('mouseup', fastCheck);
window.addEventListener('keyup', fastCheck);
window.addEventListener('mousedown', fastCheck);
Expand Down Expand Up @@ -861,6 +877,22 @@ function compare(tree1, tree2, invertible) {
return patches;
}
exports.compare = compare;
/**
* Default export for backwards compat
*/
// import just to re-export as default
var core = __webpack_require__(1);
var helpers_3 = __webpack_require__(0);
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = __assign({}, core, {
// duplex
unobserve: unobserve,
observe: observe,
generate: generate,
compare: compare,
// helpers
JsonPatchError: helpers_3.PatchError, deepClone: helpers_1._deepClone, escapePathComponent: helpers_1.escapePathComponent,
unescapePathComponent: helpers_3.unescapePathComponent });


/***/ }),
Expand Down
5 changes: 2 additions & 3 deletions dist/fast-json-patch.min.js

Large diffs are not rendered by default.

47 changes: 33 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -41,7 +41,7 @@
"sauce-connect-launcher": "^1.2.7",
"saucelabs": "^2.1.9",
"selenium-webdriver": "^4.0.0-alpha.4",
"typescript": "~3.5.2",
"typescript": "2.2.0",
"underscore": "^1.9.1",
"webpack": "^4.35.0",
"webpack-cli": "^3.3.5"
Expand All @@ -52,8 +52,11 @@
"build": "tsc && webpack",
"serve": "http-server -p 5000 --silent",
"tsc-watch": "tsc -w",
"test": "npm run tsc && npm run test-core && npm run test-duplex",
"test": "npm run tsc && npm run test-core && npm run test-duplex && npm run test-commonjs && npm run test-webpack-import && npm run test-typings",
"test-sauce": "npm run build && node test/Sauce/Runner.js",
"test-commonjs": "jasmine test/spec/commonjs/requireSpec.js",
"test-webpack-import": "webpack --env.NODE_ENV=test && jasmine test/spec/webpack/importSpec.build.js",
"test-typings": "tsc test/spec/typings/typingsSpec.ts",
"test-duplex": "jasmine DUPLEX=yes JASMINE_CONFIG_PATH=test/jasmine.json",
"test-core": "jasmine DUPLEX=no JASMINE_CONFIG_PATH=test/jasmine.json test/spec/jsonPatchTestsSpec.js test/spec/coreSpec.js test/spec/validateSpec.js",
"bench": "npm run bench-core && npm run bench-duplex",
Expand Down
15 changes: 15 additions & 0 deletions src/core.ts
Expand Up @@ -457,3 +457,18 @@ export function validate<T>(sequence: Operation[], document?: T, externalValidat
}
}
}

/**
* Default export for backwards compat
*/

export default {
JsonPatchError,
deepClone,
getValueByPointer,
applyOperation,
applyPatch,
applyReducer,
validator,
validate
}