/** * 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; }
({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; }
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; } } });
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); };
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; };
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);
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; });