Packable.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import DeveloperError from "./DeveloperError.js";
  2. /**
  3. * Static interface for types which can store their values as packed
  4. * elements in an array. These methods and properties are expected to be
  5. * defined on a constructor function.
  6. *
  7. * @interface Packable
  8. *
  9. * @see PackableForInterpolation
  10. */
  11. const Packable = {
  12. /**
  13. * The number of elements used to pack the object into an array.
  14. * @type {number}
  15. */
  16. packedLength: undefined,
  17. /**
  18. * Stores the provided instance into the provided array.
  19. * @function
  20. *
  21. * @param {*} value The value to pack.
  22. * @param {number[]} array The array to pack into.
  23. * @param {number} [startingIndex=0] The index into the array at which to start packing the elements.
  24. */
  25. pack: DeveloperError.throwInstantiationError,
  26. /**
  27. * Retrieves an instance from a packed array.
  28. * @function
  29. *
  30. * @param {number[]} array The packed array.
  31. * @param {number} [startingIndex=0] The starting index of the element to be unpacked.
  32. * @param {object} [result] The object into which to store the result.
  33. * @returns {object} The modified result parameter or a new Object instance if one was not provided.
  34. */
  35. unpack: DeveloperError.throwInstantiationError,
  36. };
  37. export default Packable;