helpers.d.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*!
  2. * https://github.com/Starcounter-Jack/JSON-Patch
  3. * (c) 2017-2022 Joachim Wester
  4. * MIT licensed
  5. */
  6. export declare function hasOwnProperty(obj: any, key: any): any;
  7. export declare function _objectKeys(obj: any): any[];
  8. /**
  9. * Deeply clone the object.
  10. * https://jsperf.com/deep-copy-vs-json-stringify-json-parse/25 (recursiveDeepCopy)
  11. * @param {any} obj value to clone
  12. * @return {any} cloned obj
  13. */
  14. export declare function _deepClone(obj: any): any;
  15. export declare function isInteger(str: string): boolean;
  16. /**
  17. * Escapes a json pointer path
  18. * @param path The raw pointer
  19. * @return the Escaped path
  20. */
  21. export declare function escapePathComponent(path: string): string;
  22. /**
  23. * Unescapes a json pointer path
  24. * @param path The escaped pointer
  25. * @return The unescaped path
  26. */
  27. export declare function unescapePathComponent(path: string): string;
  28. export declare function _getPathRecursive(root: Object, obj: Object): string;
  29. export declare function getPath(root: Object, obj: Object): string;
  30. /**
  31. * Recursively checks whether an object has any undefined values inside.
  32. */
  33. export declare function hasUndefined(obj: any): boolean;
  34. export declare type JsonPatchErrorName = 'SEQUENCE_NOT_AN_ARRAY' | 'OPERATION_NOT_AN_OBJECT' | 'OPERATION_OP_INVALID' | 'OPERATION_PATH_INVALID' | 'OPERATION_FROM_REQUIRED' | 'OPERATION_VALUE_REQUIRED' | 'OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED' | 'OPERATION_PATH_CANNOT_ADD' | 'OPERATION_PATH_UNRESOLVABLE' | 'OPERATION_FROM_UNRESOLVABLE' | 'OPERATION_PATH_ILLEGAL_ARRAY_INDEX' | 'OPERATION_VALUE_OUT_OF_BOUNDS' | 'TEST_OPERATION_FAILED';
  35. export declare class PatchError extends Error {
  36. name: JsonPatchErrorName;
  37. index?: number;
  38. operation?: any;
  39. tree?: any;
  40. constructor(message: string, name: JsonPatchErrorName, index?: number, operation?: any, tree?: any);
  41. }