From e4aa121ada32a80699a445494bf56088d5b6ee3e Mon Sep 17 00:00:00 2001 From: vvakame Date: Mon, 15 Sep 2014 23:32:25 +0900 Subject: [PATCH] refactor deep-diff.d.ts --- deep-diff/deep-diff-tests.ts | 13 +++++------ deep-diff/deep-diff.d.ts | 44 +++++++++++++++++------------------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/deep-diff/deep-diff-tests.ts b/deep-diff/deep-diff-tests.ts index 4377bddd1e..1392effb16 100644 --- a/deep-diff/deep-diff-tests.ts +++ b/deep-diff/deep-diff-tests.ts @@ -1,7 +1,7 @@ /// -import deepDiff = require('deep-diff'); -var diff = deepDiff.diff; +import _deepDiff = require('deep-diff'); +var diff = _deepDiff.diff; var lhs = { name: 'my object', @@ -23,16 +23,15 @@ var rhs = { } }; -var differences: IDiff[] = diff(lhs, rhs); +var differences: deepDiff.IDiff[] = diff(lhs, rhs); console.log(differences); // -------------------------- - -var observableDiff = deepDiff.observableDiff; -var applyChange = deepDiff.applyChange; +var observableDiff = _deepDiff.observableDiff; +var applyChange = _deepDiff.applyChange; var lhs = { name: 'my object', @@ -54,7 +53,7 @@ var rhs = { } }; -observableDiff(lhs, rhs, function (d: IDiff) { +observableDiff(lhs, rhs, function (d: deepDiff.IDiff) { // Apply all changes except those to the 'name' property... if (d.path.length !== 1 || d.path.join('.') !== 'name') { applyChange(lhs, rhs, d); diff --git a/deep-diff/deep-diff.d.ts b/deep-diff/deep-diff.d.ts index 07fb0eb232..1b96960a3b 100644 --- a/deep-diff/deep-diff.d.ts +++ b/deep-diff/deep-diff.d.ts @@ -3,27 +3,26 @@ // Definitions by: ZauberNerd // Definitions: https://github.com/borisyankov/DefinitelyTyped - -interface IDiff { - kind: string; - path: string[]; - lhs: any; - rhs: any; - index?: number; - item?: IDiff; -} - -interface IAccumulator { - push(diff: IDiff): void; - length: number; -} - -interface IPrefilter { - (path: string[], key: string): boolean; -} - declare module deepDiff { - export interface IDeepDiff { + interface IDiff { + kind: string; + path: string[]; + lhs: any; + rhs: any; + index?: number; + item?: IDiff; + } + + interface IAccumulator { + push(diff: IDiff): void; + length: number; + } + + interface IPrefilter { + (path: string[], key: string): boolean; + } + + interface IDeepDiff { diff(): IDiff; diff(lhs: Object, rhs: Object, prefilter?: IPrefilter, acc?: IAccumulator): IDiff[]; observableDiff(lhs: Object, rhs: Object, changes: Function, prefilter?: IPrefilter, path?: string[], key?: string, stack?: Object[]): void; @@ -35,8 +34,7 @@ declare module deepDiff { } } -declare var diff: deepDiff.IDeepDiff; - declare module "deep-diff" { + var diff: deepDiff.IDeepDiff; export = diff; -} \ No newline at end of file +}