@bbn/bbn 1.0.225 → 1.0.226

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.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Returns the value of the given field (property) from the first object matching the given filter in an array of objects.
3
+ *
4
+ * The filtering arguments follow the same scheme as bbn.fn.search.
5
+ *
6
+ * @method isWritable
7
+ * @global
8
+ * @example
9
+ * ```javascript
10
+ * class Foo {
11
+ * readonly a = 1
12
+ * b = 2
13
+ * }
14
+ * const foo = new Foo();
15
+ * bbn.fn.isWritable(foo, 'a');
16
+ * // false
17
+ * bbn.fn.isWritable(foo, 'b');
18
+ * // true
19
+ * ```
20
+ *
21
+ * @example
22
+ * ```javascript
23
+ * class Zoo {
24
+ * get a () { return 1; }
25
+ * b = 2
26
+ * }
27
+ * const zoo = new Zoo();
28
+ * bbn.fn.isWritable(zoo, 'a');
29
+ * // false
30
+ * bbn.fn.isWritable(zoo, 'b');
31
+ * // true
32
+ * ```
33
+ * @memberof bbn.fn
34
+ * @param {Object} obj The subject object
35
+ * @param {keyof Object} key The property from which the value is returned
36
+ * @returns {Boolean}
37
+ */
38
+ export default function isWritable(obj: Object, key: keyof Object): boolean;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Returns the value of the given field (property) from the first object matching the given filter in an array of objects.
3
+ *
4
+ * The filtering arguments follow the same scheme as bbn.fn.search.
5
+ *
6
+ * @method isWritable
7
+ * @global
8
+ * @example
9
+ * ```javascript
10
+ * class Foo {
11
+ * readonly a = 1
12
+ * b = 2
13
+ * }
14
+ * const foo = new Foo();
15
+ * bbn.fn.isWritable(foo, 'a');
16
+ * // false
17
+ * bbn.fn.isWritable(foo, 'b');
18
+ * // true
19
+ * ```
20
+ *
21
+ * @example
22
+ * ```javascript
23
+ * class Zoo {
24
+ * get a () { return 1; }
25
+ * b = 2
26
+ * }
27
+ * const zoo = new Zoo();
28
+ * bbn.fn.isWritable(zoo, 'a');
29
+ * // false
30
+ * bbn.fn.isWritable(zoo, 'b');
31
+ * // true
32
+ * ```
33
+ * @memberof bbn.fn
34
+ * @param {Object} obj The subject object
35
+ * @param {keyof Object} key The property from which the value is returned
36
+ * @returns {Boolean}
37
+ */
38
+ export default function isWritable(obj, key) {
39
+ var desc = Object.getOwnPropertyDescriptor(obj, key)
40
+ || Object.getOwnPropertyDescriptor(Object.getPrototypeOf(obj), key)
41
+ || {};
42
+ return Boolean(desc.writable);
43
+ }
44
+ ;
package/dist/fn.d.ts CHANGED
@@ -159,6 +159,7 @@ import isValidDimension from './fn/type/isValidDimension.js';
159
159
  import isValidName from './fn/type/isValidName.js';
160
160
  import isValue from './fn/type/isValue.js';
161
161
  import isVue from './fn/type/isVue.js';
162
+ import isWritable from './fn/object/isWritable.js';
162
163
  import iterate from './fn/loop/iterate.js';
163
164
  import lightenDarkenHex from './fn/style/lightenDarkenHex.js';
164
165
  import link from './fn/ajax/link.js';
@@ -391,6 +392,7 @@ declare const _default: {
391
392
  isValidName: typeof isValidName;
392
393
  isValue: typeof isValue;
393
394
  isVue: typeof isVue;
395
+ isWritable: typeof isWritable;
394
396
  iterate: typeof iterate;
395
397
  lightenDarkenHex: typeof lightenDarkenHex;
396
398
  link: typeof link;
package/dist/fn.js CHANGED
@@ -159,6 +159,7 @@ import isValidDimension from './fn/type/isValidDimension.js';
159
159
  import isValidName from './fn/type/isValidName.js';
160
160
  import isValue from './fn/type/isValue.js';
161
161
  import isVue from './fn/type/isVue.js';
162
+ import isWritable from './fn/object/isWritable.js';
162
163
  import iterate from './fn/loop/iterate.js';
163
164
  import lightenDarkenHex from './fn/style/lightenDarkenHex.js';
164
165
  import link from './fn/ajax/link.js';
@@ -391,6 +392,7 @@ export default {
391
392
  isValidName: isValidName,
392
393
  isValue: isValue,
393
394
  isVue: isVue,
395
+ isWritable: isWritable,
394
396
  iterate: iterate,
395
397
  lightenDarkenHex: lightenDarkenHex,
396
398
  link: link,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbn/bbn",
3
- "version": "1.0.225",
3
+ "version": "1.0.226",
4
4
  "description": "Javascript toolkit",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",