@barchart/portfolio-api-common 1.2.82 → 1.2.83

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.
@@ -276,7 +276,7 @@ module.exports = (() => {
276
276
 
277
277
  const existingBarchartSymbols = this.getPositionSymbols(false);
278
278
 
279
- removePositionItem.call(this, this._items.find((item) => item.position.position === position.position));
279
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
280
280
 
281
281
  summaries.forEach((summary) => {
282
282
  addSummaryCurrent(this._summariesCurrent, summary, this._currentSummaryFrame, this._currentSummaryRange);
@@ -336,7 +336,7 @@ module.exports = (() => {
336
336
  assert.argumentIsRequired(position, 'position', Object);
337
337
  assert.argumentIsRequired(position.position, 'position.position', String);
338
338
 
339
- removePositionItem.call(this, this._items.find((item) => item.position.position === position.position));
339
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
340
340
 
341
341
  recalculatePercentages.call(this);
342
342
  }
@@ -391,17 +391,19 @@ module.exports = (() => {
391
391
  }
392
392
 
393
393
  /**
394
- * Returns all positions which are currently locked (for editing).
394
+ * Returns a position's lock status.
395
395
  *
396
396
  * @public
397
- * @returns {Array.<Object>}
397
+ * @param {Object} position
398
+ * @return {Boolean}
398
399
  */
399
- getLockedPositions() {
400
- return this._items.filter((i) => {
401
- return i.data.locked;
402
- }).map((i) => {
403
- return i.position;
404
- });
400
+ getPositionLock(portfolio, position) {
401
+ assert.argumentIsRequired(position, 'position', Object);
402
+ assert.argumentIsRequired(position.position, 'position.position', String);
403
+
404
+ const item = this._items.find(i => i.position.position === position.position);
405
+
406
+ return is.object(item) && item.locked;
405
407
  }
406
408
 
407
409
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.2.82",
3
+ "version": "1.2.83",
4
4
  "description": "Common classes used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -1655,7 +1655,7 @@ module.exports = (() => {
1655
1655
 
1656
1656
  const existingBarchartSymbols = this.getPositionSymbols(false);
1657
1657
 
1658
- removePositionItem.call(this, this._items.find((item) => item.position.position === position.position));
1658
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
1659
1659
 
1660
1660
  summaries.forEach((summary) => {
1661
1661
  addSummaryCurrent(this._summariesCurrent, summary, this._currentSummaryFrame, this._currentSummaryRange);
@@ -1715,7 +1715,7 @@ module.exports = (() => {
1715
1715
  assert.argumentIsRequired(position, 'position', Object);
1716
1716
  assert.argumentIsRequired(position.position, 'position.position', String);
1717
1717
 
1718
- removePositionItem.call(this, this._items.find((item) => item.position.position === position.position));
1718
+ removePositionItem.call(this, this._items.find(item => item.position.position === position.position));
1719
1719
 
1720
1720
  recalculatePercentages.call(this);
1721
1721
  }
@@ -1770,17 +1770,19 @@ module.exports = (() => {
1770
1770
  }
1771
1771
 
1772
1772
  /**
1773
- * Returns all positions which are currently locked (for editing).
1773
+ * Returns a position's lock status.
1774
1774
  *
1775
1775
  * @public
1776
- * @returns {Array.<Object>}
1776
+ * @param {Object} position
1777
+ * @return {Boolean}
1777
1778
  */
1778
- getLockedPositions() {
1779
- return this._items.filter((i) => {
1780
- return i.data.locked;
1781
- }).map((i) => {
1782
- return i.position;
1783
- });
1779
+ getPositionLock(portfolio, position) {
1780
+ assert.argumentIsRequired(position, 'position', Object);
1781
+ assert.argumentIsRequired(position.position, 'position.position', String);
1782
+
1783
+ const item = this._items.find(i => i.position.position === position.position);
1784
+
1785
+ return is.object(item) && item.locked;
1784
1786
  }
1785
1787
 
1786
1788
  /**