@bbn/bbn 1.0.346 → 1.0.348

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.
@@ -97,4 +97,4 @@ import { Filter } from './filterToConditions.js';
97
97
  * @param {Number} startFrom The index from which the search should start
98
98
  * @returns {Number} The index if found, otherwise -1
99
99
  */
100
- export default function search(arr: any[], prop: Filter | object | string | ((a: any, i: string | number | symbol) => boolean), val?: any, operator?: number | string, startFrom?: number): number;
100
+ export default function search(arr: any[], prop: Filter | object | string | ((a: any, i: string | number | symbol) => boolean), val?: any, operator?: number | false | string, startFrom?: number | false): number;
@@ -3,7 +3,6 @@ import compareConditions from './compareConditions.js';
3
3
  import { filterToConditions } from './filterToConditions.js';
4
4
  import isObject from '../type/isObject.js';
5
5
  import numProperties from './numProperties.js';
6
- import isNumber from '../type/isNumber.js';
7
6
  /**
8
7
  * Retrieves the index of the array's first element corresponding to the given filter.
9
8
  *
@@ -152,25 +151,45 @@ export default function search(arr, prop, val, operator, startFrom) {
152
151
  }
153
152
  }
154
153
  if (isFn || (isObject(filter) && numProperties(filter))) {
155
- if (isNumber(operator)) {
156
- startFrom = typeof (operator) === 'number' ? operator : 0;
154
+ var dir = 'asc';
155
+ if ((startFrom === undefined) && (typeof operator !== 'string')) {
156
+ startFrom = operator;
157
157
  operator = undefined;
158
158
  }
159
- if (!isNumber(startFrom)) {
160
- startFrom = 0;
159
+ if (startFrom === false) {
160
+ startFrom = arr.length - 1;
161
+ dir = 'desc';
161
162
  }
162
163
  if (typeof filter === 'function') {
163
- for (var i = startFrom; i < arr.length; i++) {
164
- if (filter(arr[i])) {
165
- return i;
164
+ if (dir === 'desc') {
165
+ for (var i = startFrom; i >= 0; i--) {
166
+ if (filter(arr[i])) {
167
+ return i;
168
+ }
169
+ }
170
+ }
171
+ else {
172
+ for (var i = startFrom; i < arr.length; i++) {
173
+ if (filter(arr[i])) {
174
+ return i;
175
+ }
166
176
  }
167
177
  }
168
178
  }
169
179
  else {
170
180
  filter = filterToConditions(filter);
171
- for (var i = startFrom; i < arr.length; i++) {
172
- if (compareConditions(arr[i], filter)) {
173
- return i;
181
+ if (dir === 'desc') {
182
+ for (var i = startFrom; i >= 0; i--) {
183
+ if (compareConditions(arr[i], filter)) {
184
+ return i;
185
+ }
186
+ }
187
+ }
188
+ else {
189
+ for (var i = startFrom; i < arr.length; i++) {
190
+ if (compareConditions(arr[i], filter)) {
191
+ return i;
192
+ }
174
193
  }
175
194
  }
176
195
  }
@@ -7,6 +7,10 @@ export default function getCssVar(varname) {
7
7
  if (varname.indexOf("--") !== 0) {
8
8
  varname = "--" + varname;
9
9
  }
10
- return getComputedStyle(document.documentElement).getPropertyValue(varname);
10
+ var r = getComputedStyle(document.documentElement).getPropertyValue(varname);
11
+ if (typeof r === "string") {
12
+ r = r.trim();
13
+ }
14
+ return r;
11
15
  }
12
16
  ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.346",
3
+ "version": "1.0.348",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",