collect-your-stuff 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,21 +26,23 @@ declare class TreeLinker implements IsTreeNode {
26
26
  * @param {TreeLinker} [settings.prev=null] The reference to the previous linker if any
27
27
  * @param {LinkedTreeList} [settings.children=null] The references to child linkers if any
28
28
  * @param {TreeLinker} [settings.parent=null] The reference to a parent linker if any
29
+ * @param {IsArrayable<IsTreeNode>} listClass Give the type of list to use for storing the children
29
30
  */
30
- constructor({ data, next, prev, children, parent }?: {
31
+ constructor({ data, next, prev, children, parent, listClass }?: {
31
32
  data?: any;
32
33
  next?: IsTreeNode;
33
34
  prev?: IsTreeNode;
34
35
  children?: Array<any>;
35
36
  parent?: IsTreeNode;
37
+ listClass?: any;
36
38
  });
37
39
  /**
38
40
  * Create the children for this tree from an array.
39
41
  * @param {Array|null} children Provide an array of data / linker references to be children of this tree node.
40
- * @param {IsTree} classType Provide the type of IsElement to use.
42
+ * @param {IsArrayable<IsTreeNode>} listClass Give the type of list to use for storing the children
41
43
  * @return {LinkedTreeList|null}
42
44
  */
43
- childrenFromArray(children?: Array<any> | null, classType?: any): IsTree | any;
45
+ childrenFromArray(children?: Array<any> | null, listClass?: any): IsTree | any;
44
46
  /**
45
47
  * Make a new DoubleLinker from the data given if it is not already a valid Linker.
46
48
  * @param {TreeLinker|*} linker Return a valid TreeLinker instance from given data, or even an already valid one.
@@ -7,6 +7,7 @@ exports.default = void 0
7
7
  require('core-js/modules/esnext.async-iterator.map.js')
8
8
  require('core-js/modules/esnext.iterator.map.js')
9
9
  var _DoubleLinker = _interopRequireDefault(require('../doubly-linked-list/DoubleLinker'))
10
+ var _LinkedTreeList = _interopRequireDefault(require('./LinkedTreeList'))
10
11
  function _interopRequireDefault (obj) { return obj && obj.__esModule ? obj : { default: obj } }
11
12
  /**
12
13
  * TreeLinker represents a node in a LinkedTreeList having a parent (or root) and child nodes.
@@ -21,6 +22,7 @@ class TreeLinker {
21
22
  * @param {TreeLinker} [settings.prev=null] The reference to the previous linker if any
22
23
  * @param {LinkedTreeList} [settings.children=null] The references to child linkers if any
23
24
  * @param {TreeLinker} [settings.parent=null] The reference to a parent linker if any
25
+ * @param {IsArrayable<IsTreeNode>} listClass Give the type of list to use for storing the children
24
26
  */
25
27
  constructor () {
26
28
  const {
@@ -28,7 +30,8 @@ class TreeLinker {
28
30
  next = null,
29
31
  prev = null,
30
32
  children = null,
31
- parent = null
33
+ parent = null,
34
+ listClass = _LinkedTreeList.default
32
35
  } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}
33
36
  this.classType = TreeLinker
34
37
  this.data = null
@@ -40,25 +43,25 @@ class TreeLinker {
40
43
  this.next = next
41
44
  this.prev = prev
42
45
  this.parent = parent
43
- this.children = this.childrenFromArray(children)
46
+ this.children = this.childrenFromArray(children, listClass)
44
47
  }
45
48
 
46
49
  /**
47
50
  * Create the children for this tree from an array.
48
51
  * @param {Array|null} children Provide an array of data / linker references to be children of this tree node.
49
- * @param {IsTree} classType Provide the type of IsElement to use.
52
+ * @param {IsArrayable<IsTreeNode>} listClass Give the type of list to use for storing the children
50
53
  * @return {LinkedTreeList|null}
51
54
  */
52
55
  childrenFromArray () {
53
56
  const children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null
54
- const classType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TreeLinker
57
+ const listClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _LinkedTreeList.default
55
58
  if (children === null) {
56
59
  return null
57
60
  }
58
61
  // Creates a linked-tree-list to store the children.
59
- return classType.fromArray(children.map(child => Object.assign({}, child, {
62
+ return listClass.fromArray(children.map(child => Object.assign({}, child, {
60
63
  parent: this
61
- })), classType)
64
+ })), this.classType)
62
65
  }
63
66
  }
64
67
  /**
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,require("core-js/modules/esnext.async-iterator.map.js"),require("core-js/modules/esnext.iterator.map.js");var _DoubleLinker=_interopRequireDefault(require("../doubly-linked-list/DoubleLinker"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}class TreeLinker{constructor(){let{data:e=null,next:r=null,prev:t=null,children:l=null,parent:n=null}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.classType=TreeLinker,this.data=null,this.next=null,this.prev=null,this.parent=null,this.children=null,this.data=e,this.next=r,this.prev=t,this.parent=n,this.children=this.childrenFromArray(l)}childrenFromArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TreeLinker;return null===e?null:r.fromArray(e.map((e=>Object.assign({},e,{parent:this}))),r)}}TreeLinker.make=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TreeLinker;return _DoubleLinker.default.make(e,r)},TreeLinker.fromArray=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TreeLinker;return _DoubleLinker.default.fromArray(e,r)};var _default=exports.default=TreeLinker;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,require("core-js/modules/esnext.async-iterator.map.js"),require("core-js/modules/esnext.iterator.map.js");var _DoubleLinker=_interopRequireDefault(require("../doubly-linked-list/DoubleLinker")),_LinkedTreeList=_interopRequireDefault(require("./LinkedTreeList"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}class TreeLinker{constructor(){let{data:e=null,next:r=null,prev:t=null,children:l=null,parent:i=null,listClass:n=_LinkedTreeList.default}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.classType=TreeLinker,this.data=null,this.next=null,this.prev=null,this.parent=null,this.children=null,this.data=e,this.next=r,this.prev=t,this.parent=i,this.children=this.childrenFromArray(l,n)}childrenFromArray(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_LinkedTreeList.default;return null===e?null:r.fromArray(e.map((e=>Object.assign({},e,{parent:this}))),this.classType)}}TreeLinker.make=function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TreeLinker;return _DoubleLinker.default.make(e,r)},TreeLinker.fromArray=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:TreeLinker;return _DoubleLinker.default.fromArray(e,r)};var _default=exports.default=TreeLinker;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "collect-your-stuff",
3
3
  "description": "Use a variety of collections to collect your stuff when building code.",
4
- "version": "1.1.2",
4
+ "version": "1.1.4",
5
5
  "main": "dist/main.js",
6
6
  "author": "Joshua Heagle",
7
7
  "license": "GNU",