You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

34 lines
1.4 KiB

  1. import diff from 'fast-diff';
  2. import AttributeMap from './AttributeMap';
  3. import Op from './Op';
  4. declare class Delta {
  5. static Op: typeof Op;
  6. static AttributeMap: typeof AttributeMap;
  7. ops: Op[];
  8. constructor(ops?: Op[] | {
  9. ops: Op[];
  10. });
  11. insert(arg: string | object, attributes?: AttributeMap): this;
  12. delete(length: number): this;
  13. retain(length: number, attributes?: AttributeMap): this;
  14. push(newOp: Op): this;
  15. chop(): this;
  16. filter(predicate: (op: Op, index: number) => boolean): Op[];
  17. forEach(predicate: (op: Op, index: number) => void): void;
  18. map<T>(predicate: (op: Op, index: number) => T): T[];
  19. partition(predicate: (op: Op) => boolean): [Op[], Op[]];
  20. reduce<T>(predicate: (accum: T, curr: Op, index: number) => T, initialValue: T): T;
  21. changeLength(): number;
  22. length(): number;
  23. slice(start?: number, end?: number): Delta;
  24. compose(other: Delta): Delta;
  25. concat(other: Delta): Delta;
  26. diff(other: Delta, cursor?: number | diff.CursorInfo): Delta;
  27. eachLine(predicate: (line: Delta, attributes: AttributeMap, index: number) => boolean | void, newline?: string): void;
  28. invert(base: Delta): Delta;
  29. transform(index: number, priority?: boolean): number;
  30. transform(other: Delta, priority?: boolean): Delta;
  31. transformPosition(index: number, priority?: boolean): number;
  32. }
  33. export = Delta;