@barchart/portfolio-api-common 1.4.2 → 1.4.3

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.
package/.jshintrc CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "esversion": 6,
2
+ "esversion": 9,
3
3
  "validthis": true,
4
4
  "-W018": true,
5
5
  "-W093": true
package/gulpfile.js CHANGED
@@ -4,12 +4,13 @@ const fs = require('fs');
4
4
 
5
5
  const browserify = require('browserify'),
6
6
  buffer = require('vinyl-buffer'),
7
- bump = require('gulp-bump'),
7
+ exec = require('child_process').exec,
8
8
  git = require('gulp-git'),
9
9
  gitStatus = require('git-get-status'),
10
10
  glob = require('glob'),
11
11
  jasmine = require('gulp-jasmine'),
12
12
  jshint = require('gulp-jshint'),
13
+ prompt = require('gulp-prompt'),
13
14
  source = require('vinyl-source-stream');
14
15
 
15
16
  function getVersionFromPackage() {
@@ -26,10 +27,31 @@ gulp.task('ensure-clean-working-directory', (cb) => {
26
27
  });
27
28
  });
28
29
 
29
- gulp.task('bump-version', () => {
30
- return gulp.src([ './package.json' ])
31
- .pipe(bump({ type: 'patch' }))
32
- .pipe(gulp.dest('./'));
30
+ gulp.task('bump-choice', (cb) => {
31
+ const processor = prompt.prompt({
32
+ type: 'list',
33
+ name: 'bump',
34
+ message: 'What type of bump would you like to do?',
35
+ choices: ['patch', 'minor', 'major'],
36
+ }, (res) => {
37
+ global.bump = res.bump;
38
+
39
+ return cb();
40
+ });
41
+
42
+ return gulp.src(['./package.json']).pipe(processor);
43
+ });
44
+
45
+ gulp.task('bump-version', (cb) => {
46
+ exec(`npm version ${global.bump || 'patch'} --no-git-tag-version`, {
47
+ cwd: './'
48
+ }, (error) => {
49
+ if (error) {
50
+ cb(error);
51
+ }
52
+
53
+ cb();
54
+ });
33
55
  });
34
56
 
35
57
  gulp.task('commit-changes', () => {
@@ -81,6 +103,7 @@ gulp.task('execute-tests', gulp.series(
81
103
  gulp.task('release', gulp.series(
82
104
  'ensure-clean-working-directory',
83
105
  'execute-tests',
106
+ 'bump-choice',
84
107
  'bump-version',
85
108
  'commit-changes',
86
109
  'push-changes',
@@ -89,7 +112,7 @@ gulp.task('release', gulp.series(
89
112
 
90
113
  gulp.task('lint', () => {
91
114
  return gulp.src([ './**/*.js', './test/specs/**/*.js', '!./node_modules/**', '!./test/SpecRunner.js' ])
92
- .pipe(jshint({'esversion': 6}))
115
+ .pipe(jshint({'esversion': 9}))
93
116
  .pipe(jshint.reporter('default'))
94
117
  .pipe(jshint.reporter('fail'));
95
118
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-api-common",
3
- "version": "1.4.2",
3
+ "version": "1.4.3",
4
4
  "description": "Common code used by the Portfolio system",
5
5
  "author": {
6
6
  "name": "Bryan Ingle",
@@ -19,11 +19,11 @@
19
19
  "git-get-status": "^1.0.5",
20
20
  "glob": "^6.0.1",
21
21
  "gulp": "^4.0.2",
22
- "gulp-bump": "~1.0.0",
23
22
  "gulp-git": "^2.9.0",
24
23
  "gulp-jasmine": "^2.2.1",
25
- "gulp-jshint": "~2.1.0",
26
- "jshint": "2.9.5",
24
+ "gulp-jshint": "^2.1.0",
25
+ "gulp-prompt": "^1.2.0",
26
+ "jshint": "^2.10.3",
27
27
  "vinyl-buffer": "^1.0.1",
28
28
  "vinyl-source-stream": "^2.0.0"
29
29
  },
@@ -8942,7 +8942,7 @@ module.exports = (() => {
8942
8942
 
8943
8943
  return {
8944
8944
  /**
8945
- * Returns true, if the argument is a number. NaN will return false.
8945
+ * Returns true if the argument is a number. NaN will return false.
8946
8946
  *
8947
8947
  * @static
8948
8948
  * @public
@@ -8954,7 +8954,7 @@ module.exports = (() => {
8954
8954
  },
8955
8955
 
8956
8956
  /**
8957
- * Returns true, if the argument is NaN.
8957
+ * Returns true if the argument is NaN.
8958
8958
  *
8959
8959
  * @static
8960
8960
  * @public
@@ -8966,7 +8966,7 @@ module.exports = (() => {
8966
8966
  },
8967
8967
 
8968
8968
  /**
8969
- * Returns true, if the argument is a valid 32-bit integer.
8969
+ * Returns true if the argument is a valid 32-bit integer.
8970
8970
  *
8971
8971
  * @static
8972
8972
  * @public
@@ -8978,7 +8978,7 @@ module.exports = (() => {
8978
8978
  },
8979
8979
 
8980
8980
  /**
8981
- * Returns true, if the argument is a valid integer (which can exceed 32 bits); however,
8981
+ * Returns true if the argument is a valid integer (which can exceed 32 bits); however,
8982
8982
  * the check can fail above the value of Number.MAX_SAFE_INTEGER.
8983
8983
  *
8984
8984
  * @static
@@ -8991,7 +8991,7 @@ module.exports = (() => {
8991
8991
  },
8992
8992
 
8993
8993
  /**
8994
- * Returns true, if the argument is a number that is positive.
8994
+ * Returns true if the argument is a number that is positive.
8995
8995
  *
8996
8996
  * @static
8997
8997
  * @public
@@ -9003,7 +9003,7 @@ module.exports = (() => {
9003
9003
  },
9004
9004
 
9005
9005
  /**
9006
- * Returns true, if the argument is a number that is negative.
9006
+ * Returns true if the argument is a number that is negative.
9007
9007
  *
9008
9008
  * @static
9009
9009
  * @public
@@ -9015,7 +9015,19 @@ module.exports = (() => {
9015
9015
  },
9016
9016
 
9017
9017
  /**
9018
- * Returns true, if the argument is a string.
9018
+ * Returns true if the argument is iterable.
9019
+ *
9020
+ * @static
9021
+ * @public
9022
+ * @param {*} candidate
9023
+ * @returns {boolean}
9024
+ */
9025
+ iterable(candidate) {
9026
+ return !this.null(candidate) && !this.undefined(candidate) && this.fn(candidate[Symbol.iterator]);
9027
+ },
9028
+
9029
+ /**
9030
+ * Returns true if the argument is a string.
9019
9031
  *
9020
9032
  * @static
9021
9033
  * @public
@@ -9027,7 +9039,7 @@ module.exports = (() => {
9027
9039
  },
9028
9040
 
9029
9041
  /**
9030
- * Returns true, if the argument is a JavaScript Date instance.
9042
+ * Returns true if the argument is a JavaScript Date instance.
9031
9043
  *
9032
9044
  * @static
9033
9045
  * @public
@@ -9039,7 +9051,7 @@ module.exports = (() => {
9039
9051
  },
9040
9052
 
9041
9053
  /**
9042
- * Returns true, if the argument is a function.
9054
+ * Returns true if the argument is a function.
9043
9055
  *
9044
9056
  * @static
9045
9057
  * @public
@@ -9051,7 +9063,7 @@ module.exports = (() => {
9051
9063
  },
9052
9064
 
9053
9065
  /**
9054
- * Returns true, if the argument is an array.
9066
+ * Returns true if the argument is an array.
9055
9067
  *
9056
9068
  * @static
9057
9069
  * @public
@@ -9063,7 +9075,7 @@ module.exports = (() => {
9063
9075
  },
9064
9076
 
9065
9077
  /**
9066
- * Returns true, if the argument is a Boolean value.
9078
+ * Returns true if the argument is a Boolean value.
9067
9079
  *
9068
9080
  * @static
9069
9081
  * @public
@@ -9075,7 +9087,7 @@ module.exports = (() => {
9075
9087
  },
9076
9088
 
9077
9089
  /**
9078
- * Returns true, if the argument is an object.
9090
+ * Returns true if the argument is an object.
9079
9091
  *
9080
9092
  * @static
9081
9093
  * @public
@@ -9087,7 +9099,7 @@ module.exports = (() => {
9087
9099
  },
9088
9100
 
9089
9101
  /**
9090
- * Returns true, if the argument is a null value.
9102
+ * Returns true if the argument is a null value.
9091
9103
  *
9092
9104
  * @static
9093
9105
  * @public
@@ -9099,7 +9111,7 @@ module.exports = (() => {
9099
9111
  },
9100
9112
 
9101
9113
  /**
9102
- * Returns true, if the argument is an undefined value.
9114
+ * Returns true if the argument is an undefined value.
9103
9115
  *
9104
9116
  * @static
9105
9117
  * @public
@@ -9110,6 +9122,18 @@ module.exports = (() => {
9110
9122
  return candidate === undefined;
9111
9123
  },
9112
9124
 
9125
+ /**
9126
+ * Returns true if the argument is a zero-length string.
9127
+ *
9128
+ * @static
9129
+ * @public
9130
+ * @param {*} candidate
9131
+ * @returns {boolean}
9132
+ */
9133
+ zeroLengthString(candidate) {
9134
+ return this.string(candidate) && candidate.length === 0;
9135
+ },
9136
+
9113
9137
  /**
9114
9138
  * Given two classes, determines if the "child" class extends
9115
9139
  * the "parent" class (without instantiation).
@@ -9149,11 +9173,11 @@ module.exports = (() => {
9149
9173
  simple(fn) {
9150
9174
  const cache = {};
9151
9175
  return x => {
9152
- if (cache.hasOwnProperty(x)) {
9153
- return cache[x];
9154
- } else {
9155
- return cache[x] = fn(x);
9176
+ if (!cache.hasOwnProperty(x)) {
9177
+ cache[x] = fn(x);
9156
9178
  }
9179
+
9180
+ return cache[x];
9157
9181
  };
9158
9182
  },
9159
9183
 
@@ -10288,9 +10312,9 @@ module.exports = (() => {
10288
10312
 
10289
10313
  },{"./../../../lang/assert":29,"./../../../lang/is":33,"./../Component":36,"./../DataType":37,"./../Field":38,"./../Schema":39,"./ComponentBuilder":40}],42:[function(require,module,exports){
10290
10314
  /*
10291
- * big.js v5.0.3
10315
+ * big.js v5.2.2
10292
10316
  * A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
10293
- * Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
10317
+ * Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com>
10294
10318
  * https://github.com/MikeMcl/big.js/LICENCE
10295
10319
  */
10296
10320
  ;(function (GLOBAL) {
@@ -10396,7 +10420,7 @@ module.exports = (() => {
10396
10420
  Big.RM = RM;
10397
10421
  Big.NE = NE;
10398
10422
  Big.PE = PE;
10399
- Big.version = '5.0.2';
10423
+ Big.version = '5.2.2';
10400
10424
 
10401
10425
  return Big;
10402
10426
  }
@@ -10480,7 +10504,7 @@ module.exports = (() => {
10480
10504
  more = xc[i] > 5 || xc[i] == 5 &&
10481
10505
  (more || i < 0 || xc[i + 1] !== UNDEFINED || xc[i - 1] & 1);
10482
10506
  } else if (rm === 3) {
10483
- more = more || xc[i] !== UNDEFINED || i < 0;
10507
+ more = more || !!xc[0];
10484
10508
  } else {
10485
10509
  more = false;
10486
10510
  if (rm !== 0) throw Error(INVALID_RM);
@@ -10947,7 +10971,7 @@ module.exports = (() => {
10947
10971
  xc = xc.slice();
10948
10972
 
10949
10973
  // Prepend zeros to equalise exponents.
10950
- // Note: Faster to use reverse then do unshifts.
10974
+ // Note: reverse faster than unshifts.
10951
10975
  if (a = xe - ye) {
10952
10976
  if (a > 0) {
10953
10977
  ye = xe;
@@ -11019,18 +11043,19 @@ module.exports = (() => {
11019
11043
 
11020
11044
 
11021
11045
  /*
11022
- * Return a new Big whose value is the value of this Big rounded to a maximum of dp decimal
11023
- * places using rounding mode rm.
11046
+ * Return a new Big whose value is the value of this Big rounded using rounding mode rm
11047
+ * to a maximum of dp decimal places, or, if dp is negative, to an integer which is a
11048
+ * multiple of 10**-dp.
11024
11049
  * If dp is not specified, round to 0 decimal places.
11025
11050
  * If rm is not specified, use Big.RM.
11026
11051
  *
11027
- * dp? {number} Integer, 0 to MAX_DP inclusive.
11052
+ * dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
11028
11053
  * rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP)
11029
11054
  */
11030
11055
  P.round = function (dp, rm) {
11031
11056
  var Big = this.constructor;
11032
11057
  if (dp === UNDEFINED) dp = 0;
11033
- else if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
11058
+ else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP);
11034
11059
  return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm);
11035
11060
  };
11036
11061
 
@@ -11054,17 +11079,18 @@ module.exports = (() => {
11054
11079
  if (s < 0) throw Error(NAME + 'No square root');
11055
11080
 
11056
11081
  // Estimate.
11057
- s = Math.sqrt(x.toString());
11082
+ s = Math.sqrt(x + '');
11058
11083
 
11059
11084
  // Math.sqrt underflow/overflow?
11060
- // Re-estimate: pass x to Math.sqrt as integer, then adjust the result exponent.
11085
+ // Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
11061
11086
  if (s === 0 || s === 1 / 0) {
11062
11087
  c = x.c.join('');
11063
11088
  if (!(c.length + e & 1)) c += '0';
11064
- r = new Big(Math.sqrt(c).toString());
11065
- r.e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
11089
+ s = Math.sqrt(c);
11090
+ e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
11091
+ r = new Big((s == 1 / 0 ? '1e' : (s = s.toExponential()).slice(0, s.indexOf('e') + 1)) + e);
11066
11092
  } else {
11067
- r = new Big(s.toString());
11093
+ r = new Big(s);
11068
11094
  }
11069
11095
 
11070
11096
  e = r.e + (Big.DP += 4);
@@ -17088,43 +17114,48 @@ for (var i = 0; i < 256; ++i) {
17088
17114
  function bytesToUuid(buf, offset) {
17089
17115
  var i = offset || 0;
17090
17116
  var bth = byteToHex;
17091
- return bth[buf[i++]] + bth[buf[i++]] +
17092
- bth[buf[i++]] + bth[buf[i++]] + '-' +
17093
- bth[buf[i++]] + bth[buf[i++]] + '-' +
17094
- bth[buf[i++]] + bth[buf[i++]] + '-' +
17095
- bth[buf[i++]] + bth[buf[i++]] + '-' +
17096
- bth[buf[i++]] + bth[buf[i++]] +
17097
- bth[buf[i++]] + bth[buf[i++]] +
17098
- bth[buf[i++]] + bth[buf[i++]];
17117
+ // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
17118
+ return ([
17119
+ bth[buf[i++]], bth[buf[i++]],
17120
+ bth[buf[i++]], bth[buf[i++]], '-',
17121
+ bth[buf[i++]], bth[buf[i++]], '-',
17122
+ bth[buf[i++]], bth[buf[i++]], '-',
17123
+ bth[buf[i++]], bth[buf[i++]], '-',
17124
+ bth[buf[i++]], bth[buf[i++]],
17125
+ bth[buf[i++]], bth[buf[i++]],
17126
+ bth[buf[i++]], bth[buf[i++]]
17127
+ ]).join('');
17099
17128
  }
17100
17129
 
17101
17130
  module.exports = bytesToUuid;
17102
17131
 
17103
17132
  },{}],49:[function(require,module,exports){
17104
- (function (global){
17105
17133
  // Unique ID creation requires a high quality random # generator. In the
17106
17134
  // browser this is a little complicated due to unknown quality of Math.random()
17107
17135
  // and inconsistent support for the `crypto` API. We do the best we can via
17108
17136
  // feature-detection
17109
- var rng;
17110
17137
 
17111
- var crypto = global.crypto || global.msCrypto; // for IE 11
17112
- if (crypto && crypto.getRandomValues) {
17138
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto
17139
+ // implementation. Also, find the complete implementation of crypto on IE11.
17140
+ var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||
17141
+ (typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));
17142
+
17143
+ if (getRandomValues) {
17113
17144
  // WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
17114
17145
  var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
17115
- rng = function whatwgRNG() {
17116
- crypto.getRandomValues(rnds8);
17146
+
17147
+ module.exports = function whatwgRNG() {
17148
+ getRandomValues(rnds8);
17117
17149
  return rnds8;
17118
17150
  };
17119
- }
17120
-
17121
- if (!rng) {
17151
+ } else {
17122
17152
  // Math.random()-based (RNG)
17123
17153
  //
17124
17154
  // If all else fails, use Math.random(). It's fast, but is of unspecified
17125
17155
  // quality.
17126
17156
  var rnds = new Array(16);
17127
- rng = function() {
17157
+
17158
+ module.exports = function mathRNG() {
17128
17159
  for (var i = 0, r; i < 16; i++) {
17129
17160
  if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
17130
17161
  rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
@@ -17134,9 +17165,6 @@ if (!rng) {
17134
17165
  };
17135
17166
  }
17136
17167
 
17137
- module.exports = rng;
17138
-
17139
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
17140
17168
  },{}],50:[function(require,module,exports){
17141
17169
  var rng = require('./lib/rng');
17142
17170
  var bytesToUuid = require('./lib/bytesToUuid');
@@ -17146,30 +17174,40 @@ var bytesToUuid = require('./lib/bytesToUuid');
17146
17174
  // Inspired by https://github.com/LiosK/UUID.js
17147
17175
  // and http://docs.python.org/library/uuid.html
17148
17176
 
17149
- // random #'s we need to init node and clockseq
17150
- var _seedBytes = rng();
17151
-
17152
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
17153
- var _nodeId = [
17154
- _seedBytes[0] | 0x01,
17155
- _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
17156
- ];
17157
-
17158
- // Per 4.2.2, randomize (14 bit) clockseq
17159
- var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
17177
+ var _nodeId;
17178
+ var _clockseq;
17160
17179
 
17161
17180
  // Previous uuid creation time
17162
- var _lastMSecs = 0, _lastNSecs = 0;
17181
+ var _lastMSecs = 0;
17182
+ var _lastNSecs = 0;
17163
17183
 
17164
- // See https://github.com/broofa/node-uuid for API details
17184
+ // See https://github.com/uuidjs/uuid for API details
17165
17185
  function v1(options, buf, offset) {
17166
17186
  var i = buf && offset || 0;
17167
17187
  var b = buf || [];
17168
17188
 
17169
17189
  options = options || {};
17170
-
17190
+ var node = options.node || _nodeId;
17171
17191
  var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
17172
17192
 
17193
+ // node and clockseq need to be initialized to random values if they're not
17194
+ // specified. We do this lazily to minimize issues related to insufficient
17195
+ // system entropy. See #189
17196
+ if (node == null || clockseq == null) {
17197
+ var seedBytes = rng();
17198
+ if (node == null) {
17199
+ // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
17200
+ node = _nodeId = [
17201
+ seedBytes[0] | 0x01,
17202
+ seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]
17203
+ ];
17204
+ }
17205
+ if (clockseq == null) {
17206
+ // Per 4.2.2, randomize (14 bit) clockseq
17207
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
17208
+ }
17209
+ }
17210
+
17173
17211
  // UUID timestamps are 100 nano-second units since the Gregorian epoch,
17174
17212
  // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
17175
17213
  // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
@@ -17229,7 +17267,6 @@ function v1(options, buf, offset) {
17229
17267
  b[i++] = clockseq & 0xff;
17230
17268
 
17231
17269
  // `node`
17232
- var node = options.node || _nodeId;
17233
17270
  for (var n = 0; n < 6; ++n) {
17234
17271
  b[i + n] = node[n];
17235
17272
  }
@@ -17247,7 +17284,7 @@ function v4(options, buf, offset) {
17247
17284
  var i = buf && offset || 0;
17248
17285
 
17249
17286
  if (typeof(options) == 'string') {
17250
- buf = options == 'binary' ? new Array(16) : null;
17287
+ buf = options === 'binary' ? new Array(16) : null;
17251
17288
  options = null;
17252
17289
  }
17253
17290
  options = options || {};