repository-provider 25.5.13 → 26.0.0
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/package.json +1 -1
- package/src/attribute.mjs +4 -4
- package/src/base-object.mjs +10 -1
package/package.json
CHANGED
package/src/attribute.mjs
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @property {string} type
|
|
6
6
|
* @property {boolean} writable
|
|
7
7
|
* @property {boolean} private
|
|
8
|
+
* @property {string} description
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -145,12 +146,11 @@ export function getAttribute(object, name) {
|
|
|
145
146
|
* In other words only produce key value pairs if value is defined.
|
|
146
147
|
* @param {Object} object
|
|
147
148
|
* @param {Object} initial
|
|
148
|
-
* @param {
|
|
149
|
+
* @param {Object} attibutes to operator on
|
|
149
150
|
* @return {Object} initial + defined values
|
|
150
151
|
*/
|
|
151
|
-
export function optionJSON(object, initial = {},
|
|
152
|
-
return Object.keys(
|
|
153
|
-
.filter(key => skip.indexOf(key) < 0)
|
|
152
|
+
export function optionJSON(object, initial = {}, attributes=object.constructor.attributes) {
|
|
153
|
+
return Object.keys(attributes || {})
|
|
154
154
|
.reduce((a, c) => {
|
|
155
155
|
const value = object[c];
|
|
156
156
|
if (value !== undefined && !(value instanceof Function)) {
|
package/src/base-object.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { definePropertiesFromOptions, mapAttributes } from "./attribute.mjs";
|
|
|
6
6
|
*/
|
|
7
7
|
export class BaseObject {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Attributes definitions
|
|
10
10
|
*/
|
|
11
11
|
static get attributes() {
|
|
12
12
|
return {
|
|
@@ -42,6 +42,15 @@ export class BaseObject {
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* @return {Object} writable attributes
|
|
47
|
+
*/
|
|
48
|
+
static get writableAttributes() {
|
|
49
|
+
return Object.fromEntries(
|
|
50
|
+
Object.entries(this.attributes).filter(([k, v]) => v.writable)
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
/**
|
|
46
55
|
* Map attributes between external and internal representation.
|
|
47
56
|
* @return {Object}
|