mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
okay, I managed to get linting working properly so here's the linted version
This commit is contained in:
parent
f4cff5517c
commit
f86348d426
@ -1,5 +1,4 @@
|
||||
import _deepDiff = require('deep-diff');
|
||||
const diff = _deepDiff.diff;
|
||||
import { diff, observableDiff, applyChange, Diff } from 'deep-diff';
|
||||
|
||||
let lhs = {
|
||||
name: 'my object',
|
||||
@ -21,15 +20,12 @@ let rhs = {
|
||||
}
|
||||
};
|
||||
|
||||
const differences: Array<deepDiff.Diff<any>> = diff(lhs, rhs);
|
||||
const differences: Array<Diff<any>> = diff(lhs, rhs);
|
||||
|
||||
console.log(differences);
|
||||
|
||||
// --------------------------
|
||||
|
||||
const observableDiff = _deepDiff.observableDiff;
|
||||
const applyChange = _deepDiff.applyChange;
|
||||
|
||||
lhs = {
|
||||
name: 'my object',
|
||||
description: 'it\'s an object!',
|
||||
|
||||
123
types/deep-diff/index.d.ts
vendored
123
types/deep-diff/index.d.ts
vendored
@ -1,79 +1,60 @@
|
||||
// Type definitions for deep-diff 1.0.2
|
||||
// Type definitions for deep-diff 1.0
|
||||
// Project: https://github.com/flitbit/diff/
|
||||
// Definitions by: ZauberNerd <https://github.com/ZauberNerd>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare namespace deepDiff {
|
||||
|
||||
interface DiffNew<RHS,Kind='N'> {
|
||||
kind: Kind;
|
||||
path?: any[];
|
||||
rhs: RHS;
|
||||
}
|
||||
|
||||
interface DiffDeleted<LHS,Kind='D'> {
|
||||
kind: Kind;
|
||||
path?: any[];
|
||||
lhs: LHS;
|
||||
}
|
||||
|
||||
interface DiffEdit<LHS,RHS=LHS,Kind='E'> {
|
||||
kind: Kind;
|
||||
path?: any[];
|
||||
lhs: LHS;
|
||||
rhs: RHS;
|
||||
}
|
||||
|
||||
interface DiffArray<LHS,RHS=LHS,Kind='A'> {
|
||||
kind: Kind;
|
||||
path?: any[];
|
||||
index: number;
|
||||
item: Diff<LHS,RHS>;
|
||||
}
|
||||
|
||||
type Diff<LHS,RHS=LHS> = DiffNew<RHS> | DiffDeleted<LHS> | DiffEdit<LHS,RHS> | DiffArray<LHS,RHS>;
|
||||
|
||||
interface PreFilterFunction {
|
||||
(path: any[], key: any): boolean;
|
||||
}
|
||||
interface PreFilterObject<LHS,RHS=LHS> {
|
||||
prefilter?(path: any[], key: any): boolean;
|
||||
normalize?(currentPath: any, key: any, lhs: LHS, rhs: RHS): [ LHS, RHS ] | undefined;
|
||||
}
|
||||
type PreFilter<LHS,RHS=LHS> = PreFilterFunction | PreFilterObject<LHS,RHS>;
|
||||
|
||||
interface Accumulator<LHS,RHS=LHS> {
|
||||
push(diff: Diff<LHS,RHS>): void;
|
||||
length: number;
|
||||
}
|
||||
|
||||
interface Observer<LHS,RHS=LHS> {
|
||||
(diff: Diff<LHS,RHS>): void;
|
||||
}
|
||||
|
||||
interface Filter<LHS,RHS=LHS> {
|
||||
(target: LHS, source: RHS, change: Diff<LHS,RHS>): boolean;
|
||||
}
|
||||
|
||||
interface DeepDiff {
|
||||
diff<LHS,RHS=LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS,RHS>): Diff<LHS,RHS>[] | undefined;
|
||||
diff<LHS,RHS=LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS,RHS>, acc?: Accumulator<LHS,RHS>): Accumulator<LHS,RHS>;
|
||||
orderIndependentDiff: typeof DeepDiff.diff;
|
||||
observableDiff<LHS,RHS=LHS>(lhs: LHS, rhs: RHS, observer?: Observer<LHS,RHS>, prefilter?: PreFilter<LHS,RHS>, orderIndependent?: boolean): Diff<LHS,RHS>[];
|
||||
orderIndependentDeepDiff<LHS,RHS=LHS>(lhs: LHS, rhs: RHS, changes: Diff<LHS,RHS>[], prefilter: PreFilter<LHS,RHS>, path: any[], key: any, stack: any[]): void;
|
||||
orderIndepHash(object: any): number;
|
||||
applyDiff<LHS,RHS=LHS>(target: LHS, source: RHS, filter?: Filter<LHS,RHS>): void;
|
||||
applyChange<LHS,RHS>(target: LHS, source: any, change: Diff<LHS,RHS>): void;
|
||||
revertChange<LHS,RHS=LHS>(target: LHS, source: any, change: Diff<LHS,RHS>): void;
|
||||
isConflict(): boolean;
|
||||
noConflict(): DeepDiff;
|
||||
}
|
||||
export interface DiffNew<RHS, Kind = 'N'> {
|
||||
kind: Kind;
|
||||
path?: any[];
|
||||
rhs: RHS;
|
||||
}
|
||||
|
||||
declare var DeepDiff: deepDiff.DeepDiff;
|
||||
|
||||
declare module "deep-diff" {
|
||||
var diff: deepDiff.DeepDiff;
|
||||
export = diff;
|
||||
export interface DiffDeleted<LHS, Kind = 'D'> {
|
||||
kind: Kind;
|
||||
path?: any[];
|
||||
lhs: LHS;
|
||||
}
|
||||
|
||||
export interface DiffEdit<LHS, RHS = LHS, Kind = 'E'> {
|
||||
kind: Kind;
|
||||
path?: any[];
|
||||
lhs: LHS;
|
||||
rhs: RHS;
|
||||
}
|
||||
|
||||
export interface DiffArray<LHS, RHS = LHS, Kind = 'A'> {
|
||||
kind: Kind;
|
||||
path?: any[];
|
||||
index: number;
|
||||
item: Diff<LHS, RHS>;
|
||||
}
|
||||
|
||||
export type Diff<LHS, RHS = LHS> = DiffNew<RHS> | DiffDeleted<LHS> | DiffEdit<LHS, RHS> | DiffArray<LHS, RHS>;
|
||||
|
||||
export type PreFilterFunction = (path: any[], key: any) => boolean;
|
||||
export interface PreFilterObject<LHS, RHS = LHS> {
|
||||
prefilter?(path: any[], key: any): boolean;
|
||||
normalize?(currentPath: any, key: any, lhs: LHS, rhs: RHS): [ LHS, RHS ] | undefined;
|
||||
}
|
||||
export type PreFilter<LHS, RHS = LHS> = PreFilterFunction | PreFilterObject<LHS, RHS>;
|
||||
|
||||
export interface Accumulator<LHS, RHS = LHS> {
|
||||
push(diff: Diff<LHS, RHS>): void;
|
||||
length: number;
|
||||
}
|
||||
|
||||
export type Observer<LHS, RHS = LHS> = (diff: Diff<LHS, RHS>) => void;
|
||||
|
||||
export type Filter<LHS, RHS = LHS> = (target: LHS, source: RHS, change: Diff<LHS, RHS>) => boolean;
|
||||
|
||||
export function diff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS, RHS>): Array<Diff<LHS, RHS>> | undefined;
|
||||
export function diff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS, RHS>, acc?: Accumulator<LHS, RHS>): Accumulator<LHS, RHS>;
|
||||
export function orderIndependentDiff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS, RHS>): Array<Diff<LHS, RHS>> | undefined;
|
||||
export function orderIndependentDiff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, prefilter?: PreFilter<LHS, RHS>, acc?: Accumulator<LHS, RHS>): Accumulator<LHS, RHS>;
|
||||
export function observableDiff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, observer?: Observer<LHS, RHS>, prefilter?: PreFilter<LHS, RHS>, orderIndependent?: boolean): Array<Diff<LHS, RHS>>;
|
||||
export function orderIndependentDeepDiff<LHS, RHS = LHS>(lhs: LHS, rhs: RHS, changes: Array<Diff<LHS, RHS>>, prefilter: PreFilter<LHS, RHS>, path: any[], key: any, stack: any[]): void;
|
||||
export function orderIndepHash(object: any): number;
|
||||
export function applyDiff<LHS, RHS = LHS>(target: LHS, source: RHS, filter?: Filter<LHS, RHS>): void;
|
||||
export function applyChange<LHS>(target: LHS, source: any, change: Diff<LHS, any>): void;
|
||||
export function revertChange<LHS>(target: LHS, source: any, change: Diff<LHS, any>): void;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user