本文整理汇总了TypeScript中deep-equal类的典型用法代码示例。如果您正苦于以下问题:TypeScript deep-equal类的具体用法?TypeScript deep-equal怎么用?TypeScript deep-equal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了deep-equal类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: deepEqual
import * as deepEqual from "deep-equal";
let isDeepEqual1: boolean = deepEqual({}, {});
let isDeepEqual2: boolean = deepEqual({}, {}, { strict: true });
let isDeepEqual3: boolean = deepEqual({}, {}, { strict: false });
console.log(isDeepEqual1, isDeepEqual2, isDeepEqual3);
示例2: concatSegment
/**
* Concat Segment
*
* @private
* @param {Feature<LineString>} line LineString
* @param {Feature<LineString>} segment 2-vertex LineString
* @returns {Feature<LineString>} concat linestring
*/
function concatSegment(line, segment) {
var coords = getCoords(segment);
var lineCoords = getCoords(line);
var start = lineCoords[0];
var end = lineCoords[lineCoords.length - 1];
var geom = line.geometry.coordinates;
if (equal(coords[0], start)) geom.unshift(coords[1]);
else if (equal(coords[0], end)) geom.push(coords[1]);
else if (equal(coords[1], start)) geom.unshift(coords[0]);
else if (equal(coords[1], end)) geom.push(coords[0]);
return line;
}
示例3:
({method, pathRegex, queryParamsObject, bodyRestriction = {}}: MockedCall) => {
if (method !== this.req.method) {
return false;
}
if (!new RegExp(pathRegex).test(this.url)) {
return false;
}
const contentTypeIsApplicationJson = this.request.header['content-type'] === 'application/json';
if (queryParamsObject) {
const splitUrl = this.url.split('?');
if (splitUrl.length < 2) {
return false;
}
const queryParamsOnUrl = queryString.parse(splitUrl[1]);
if (!deepEquals(queryParamsOnUrl, queryParamsObject)) {
return false;
}
}
if (bodyRestriction.regex) {
const requestBodyAsString = contentTypeIsApplicationJson
? JSON.stringify(this.request.body)
: this.request.body;
if (!new RegExp(bodyRestriction.regex).test(requestBodyAsString)) {
return false;
}
}
if (
bodyRestriction.minimalObject &&
(!contentTypeIsApplicationJson || !isSubset(this.request.body, bodyRestriction.minimalObject))
) {
return false;
}
if (
bodyRestriction.object &&
(!contentTypeIsApplicationJson || !deepEquals(this.request.body, bodyRestriction.object))
) {
return false;
}
return true;
}
示例4: featureEach
featureEach(tree.search(segment), function (match) {
if (doesOverlaps === false) {
var coordsSegment = getCoords(segment).sort();
var coordsMatch: any = getCoords(match).sort();
// Segment overlaps feature
if (equal(coordsSegment, coordsMatch)) {
doesOverlaps = true;
// Overlaps already exists - only append last coordinate of segment
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
else overlapSegment = segment;
// Match segments which don't share nodes (Issue #901)
} else if (
(tolerance === 0) ?
booleanPointOnLine(coordsSegment[0], match) && booleanPointOnLine(coordsSegment[1], match) :
nearestPointOnLine(match, coordsSegment[0]).properties.dist <= tolerance &&
nearestPointOnLine(match, coordsSegment[1]).properties.dist <= tolerance) {
doesOverlaps = true;
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
else overlapSegment = segment;
} else if (
(tolerance === 0) ?
booleanPointOnLine(coordsMatch[0], segment) && booleanPointOnLine(coordsMatch[1], segment) :
nearestPointOnLine(segment, coordsMatch[0]).properties.dist <= tolerance &&
nearestPointOnLine(segment, coordsMatch[1]).properties.dist <= tolerance) {
// Do not define (doesOverlap = true) since more matches can occur within the same segment
// doesOverlaps = true;
if (overlapSegment) overlapSegment = concatSegment(overlapSegment, match);
else overlapSegment = match;
}
}
});
示例5: function
target.prototype.shouldComponentUpdate = function (nextProps: Object) {
let _nextProps = nextProps, _props = this.props;
if (subprop) {
_nextProps = Object.assign({}, nextProps);
_props = Object.assign({}, this.props);
if (typeof subprop === 'string') {
_nextProps = _nextProps[subprop];
_props = _props[subprop];
} else if (typeof subprop === 'function') {
_nextProps = subprop(_nextProps);
_props = subprop(_props);
}
}
return !deepEqual(_nextProps, _props);
};
示例6: return
return (serverCall: Call) => {
if (serverCall.method !== call.method) {
return false;
}
if (!new RegExp(call.pathRegex).test(serverCall.path)) {
return false;
}
const contentTypeIsApplicationJson = serverCall.headers['content-type'] === 'application/json';
const callBodyAsString = contentTypeIsApplicationJson ? JSON.stringify(serverCall.body) : serverCall.body;
if (call.bodyRestriction) {
if (call.bodyRestriction.exactText) {
if (callBodyAsString !== call.bodyRestriction.exactText) {
return false;
}
} else if (call.bodyRestriction.regex) {
if (!new RegExp(call.bodyRestriction.regex).test(callBodyAsString)) {
return false;
}
}
if (call.bodyRestriction.exactObject) {
if (!deepEquals(serverCall.body, call.bodyRestriction.exactObject)) {
return false;
}
} else if (call.bodyRestriction.minimalObject) {
if (!isSubset(serverCall.body, call.bodyRestriction.minimalObject)) {
return false;
}
}
}
return true;
};
示例7: it
it('normal object case #2', () => {
const schema = json2schema("Test", {
"Result": {
"Age": null,
"ApplyRemark": null,
"CompanyName": null,
"IsChecked": null,
"IsScanCode": true,
"JobTitle": null,
"MRHeadImg": null,
"MRKid": 0,
"MobilePhone": null,
"NewDoctorCount": null,
"QRcode": null,
"Reason": null,
"Sex": null,
"TrueName": null
},
"State": 1
});
expect(deepEqual(schema, {
"$schema": "http://json-schema.org/draft-04/schema#",
"properties": {
"Result": {
"properties": {
"Age": {
"type": "null"
},
"ApplyRemark": {
"type": "null"
},
"CompanyName": {
"type": "null"
},
"IsChecked": {
"type": "null"
},
"IsScanCode": {
"type": "boolean"
},
"JobTitle": {
"type": "null"
},
"MRHeadImg": {
"type": "null"
},
"MRKid": {
"type": "number"
},
"MobilePhone": {
"type": "null"
},
"NewDoctorCount": {
"type": "null"
},
"QRcode": {
"type": "null"
},
"Reason": {
"type": "null"
},
"Sex": {
"type": "null"
},
"TrueName": {
"type": "null"
},
},
"required": [
"Age",
"ApplyRemark",
"CompanyName",
"IsChecked",
"IsScanCode",
"JobTitle",
"MRHeadImg",
"MRKid",
"MobilePhone",
"NewDoctorCount",
"QRcode",
"Reason",
"Sex",
"TrueName",
],
"type": "object",
},
"State": {
"type": "number"
},
},
"required": [
"Result",
"State"
],
"title": "Test",
"type": "object"
})).to.be.true;
});