Home Reference Source Repository

src/IndexedApi.js

  1.  
  2. /**
  3. Aggregation api for properties providing indexed or array-like access to child properties.
  4.  
  5. @see {@link ArrayProperty}
  6. @see {@link IndexedProperty}
  7. */
  8. export default class IndexedApi {
  9. constructor(property) {
  10. this._property = property;
  11. }
  12.  
  13. impl() {
  14. return this._property.__();
  15. }
  16.  
  17. isActive() {
  18. return this._property.isActive();
  19. }
  20.  
  21. shadow() {
  22. return this._property._();
  23. }
  24.  
  25. //------------------------------------------------------------------------------------------------------
  26. // Select Array methods:
  27. // (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)
  28. //------------------------------------------------------------------------------------------------------
  29.  
  30. get length() {
  31. if (this.isActive()) {
  32. return this.impl().length;
  33. }
  34. }
  35.  
  36. clear() {
  37. if (this.isActive()) {
  38. this.impl().clear();
  39. }
  40. }
  41.  
  42. concat(...values) {
  43. if (this.isActive()) {
  44. return this.impl().concat(...values);
  45. }
  46. }
  47.  
  48. pop() {
  49. if (this.isActive()) {
  50. return this.impl().pop();
  51. }
  52. }
  53.  
  54. push(...values) {
  55. if (this.isActive()) {
  56. return this.impl().push(...values);
  57. }
  58. }
  59.  
  60. remove(idx) {
  61. if (this.isActive()) {
  62. return this.impl().remove(idx);
  63. }
  64. }
  65.  
  66. shift() {
  67. if (this.isActive()) {
  68. return this.impl().shift();
  69. }
  70. }
  71.  
  72. splice(start, deleteCount, ...newItems) {
  73. if (this.isActive()) {
  74. return this.impl().splice(start, deleteCount, ...newItems);
  75. }
  76. }
  77.  
  78. unshift(...values) {
  79. if (this.isActive()) {
  80. return this.impl().unshift(...values);
  81. }
  82. }
  83. }