@bbn/bbn 2.0.178 → 2.0.180

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.
@@ -978,13 +978,18 @@ export class bbnDt {
978
978
  if (!chosenUnit) {
979
979
  throw new Error('Cannot guess unit for fromNow');
980
980
  }
981
- const diff = this.diff(temp, chosenUnit);
981
+ let diff = this.diff(temp, chosenUnit);
982
982
  const rtf = new Intl.RelativeTimeFormat([bbn.env.lang, ...navigator.languages], { numeric: 'auto' });
983
983
  const match = getRow(units, d => d[0] === chosenUnit);
984
984
  if (!match) {
985
985
  throw new Error('Invalid unit for fromNow: ' + unit);
986
986
  }
987
- const [, rtfUnit] = match; // [shortUnit, rtfUnit, ms]
987
+ let [, rtfUnit] = match; // [shortUnit, rtfUnit, ms]
988
+ if (rtfUnit === 'millisecond') {
989
+ rtfUnit = 'second';
990
+ diff = Math.round(diff / 1000);
991
+ }
992
+ bbn.fn.log("FROM NOW", diff, rtfUnit, rtf);
988
993
  return rtf.format(diff, rtfUnit);
989
994
  }
990
995
  from(date, unit = '') {
@@ -6,7 +6,7 @@ const units = [
6
6
  ['h', "hour", 60 * 60 * 1000],
7
7
  ['i', "minute", 60 * 1000],
8
8
  ['s', "second", 1000],
9
- ['l', "millisecond", 1]
9
+ ['x', "millisecond", 1]
10
10
  ];
11
11
  const unitsCorrespondence = {
12
12
  'years': 'y',
@@ -50,6 +50,12 @@ const unitsCorrespondence = {
50
50
  'HH': 'h',
51
51
  'hr': 'h',
52
52
  'hh': 'h',
53
+ 'milliseconds': 'x',
54
+ 'millisecond': 'x',
55
+ 'Milliseconds': 'x',
56
+ 'Millisecond': 'x',
57
+ 'MILLISECONDS': 'x',
58
+ 'MILLISECOND': 'x',
53
59
  'minutes': 'i',
54
60
  'minute': 'i',
55
61
  'Minutes': 'i',
@@ -61,9 +67,9 @@ const unitsCorrespondence = {
61
67
  'mn': 'i',
62
68
  'mm': 'i',
63
69
  'min': 'i',
64
- 'ms': 'l',
65
- 'SSS': 'l',
66
- 'sss': 'l',
70
+ 'ms': 'x',
71
+ 'SSS': 'x',
72
+ 'sss': 'x',
67
73
  'SS': 's',
68
74
  'ss': 's',
69
75
  'seconds': 's',
@@ -101,7 +107,7 @@ const unitsMap = {
101
107
  'h': 'Hours',
102
108
  'i': 'Minutes',
103
109
  's': 'Seconds',
104
- 'l': 'Milliseconds',
110
+ 'x': 'Milliseconds',
105
111
  'z': 'Offset'
106
112
  };
107
113
  const formatsMap = {
@@ -113,6 +119,7 @@ const formatsMap = {
113
119
  'h': 'HH',
114
120
  'i': 'II',
115
121
  's': 'SS',
122
+ 'x': 'SSS',
116
123
  'z': 'Z'
117
124
  };
118
125
  export { units, unitsCorrespondence, unitsMap, formatsMap };
@@ -59,7 +59,6 @@ export default function stream(url, success, data, failure, abort, finished) {
59
59
  }
60
60
  }
61
61
  };
62
- const chrono = bbn.fn.startChrono();
63
62
  const loader = fetch(url, {
64
63
  method: 'POST', // *GET, POST, PUT, DELETE, etc.
65
64
  mode: 'cors', // no-cors, *cors, same-origin
@@ -75,7 +74,6 @@ export default function stream(url, success, data, failure, abort, finished) {
75
74
  body: JSON.stringify(data || {}) // body data type must match "Content-Type" header
76
75
  })
77
76
  .then(response => {
78
- bbn.fn.log("RESPONSE IN " + bbn.fn.stopChrono(chrono, true) + " SECS");
79
77
  if (response.body) {
80
78
  const reader = response.body.getReader();
81
79
  const isFn = isFunction(success);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "2.0.178",
3
+ "version": "2.0.180",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",