@lumjs/compat 1.1.0 → 1.3.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/CHANGELOG.md +17 -1
- package/README.md +10 -13
- package/lib/index.js +1 -1
- package/lib/v4/descriptors.js +9 -2
- package/lib/v4/index.js +58 -0
- package/lib/v4/loadtracker.js +1 -1
- package/lib/v4/object-helpers.js +15 -12
- package/lib/v4/promise.js +23 -12
- package/lib/v4/prop.js +1 -1
- package/package.json +5 -3
- package/lib/v4/meta.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [1.3.0] - 2022-10-13
|
|
10
|
+
### Changed
|
|
11
|
+
- Bumped `@lumjs/core` to `1.6.1`.
|
|
12
|
+
- Rewrote `v4/index` to use `core.buildModule()` and lazy-loading.
|
|
13
|
+
|
|
14
|
+
## [1.2.0] - 2022-09-12
|
|
15
|
+
### Changed
|
|
16
|
+
- Updated almost all of the DocBlocks for better documentation.
|
|
17
|
+
- Updated README for similar reasons.
|
|
18
|
+
- Changed `v4/meta` into a top-level `v4` that includes all sub-modules.
|
|
19
|
+
- Bumped `@lumjs/core` dependency version to latest.
|
|
20
|
+
### Fixed
|
|
21
|
+
- Fixed a bug in the *default* module.
|
|
22
|
+
|
|
9
23
|
## [1.1.0] - 2022-08-11
|
|
10
24
|
### Changed
|
|
11
25
|
- Moved all *v4* stuff into a new `v4` sub-module.
|
|
@@ -20,7 +34,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
20
34
|
### Added
|
|
21
35
|
- Initial release.
|
|
22
36
|
|
|
23
|
-
[Unreleased]: https://github.com/supernovus/lum.compat.js/compare/v1.
|
|
37
|
+
[Unreleased]: https://github.com/supernovus/lum.compat.js/compare/v1.3.0...HEAD
|
|
38
|
+
[1.3.0]: https://github.com/supernovus/lum.compat.js/compare/v1.2.0...v1.3.0
|
|
39
|
+
[1.2.0]: https://github.com/supernovus/lum.compat.js/compare/v1.1.0...v1.2.0
|
|
24
40
|
[1.1.0]: https://github.com/supernovus/lum.compat.js/compare/v1.0.0...v1.1.0
|
|
25
41
|
[1.0.0]: https://github.com/supernovus/lum.compat.js/releases/tag/v1.0.0
|
|
26
42
|
|
package/README.md
CHANGED
|
@@ -23,22 +23,19 @@ exported from this library.
|
|
|
23
23
|
|
|
24
24
|
The main entrypoint is reserved for generic compatibility functions.
|
|
25
25
|
|
|
26
|
-
### `@lumjs/compat/v4
|
|
26
|
+
### `@lumjs/compat/v4`
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
had been in the original `core` library in the legacy `v4` but during the
|
|
30
|
-
early stages of the rewrite I decided were just bloat that could be done better.
|
|
28
|
+
The `v4` compatibility namespace. Includes all `v4` modules in one simple object.
|
|
31
29
|
|
|
32
|
-
|
|
|
30
|
+
| Property | Description |
|
|
33
31
|
| --------------- | --------------------------------------------------------- |
|
|
34
|
-
| `descriptors` |
|
|
35
|
-
| `DESC` | The
|
|
36
|
-
| `prop()` |
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
`
|
|
41
|
-
dark magic that was the `descriptors` module.
|
|
32
|
+
| `descriptors` | The `v4/descriptors` module. |
|
|
33
|
+
| `DESC` | The `v4/descriptors.DESC` factory object. |
|
|
34
|
+
| `prop()` | The `v4/prop` module. |
|
|
35
|
+
| `deprecated()` | The `v4/deprecated` module. |
|
|
36
|
+
| `LoadTracker` | The `v4/loadtracker` module. |
|
|
37
|
+
| `Promise` | The `v4/promise` module. |
|
|
38
|
+
| `obj` | The `v4/object-helpers` module. |
|
|
42
39
|
|
|
43
40
|
## Official URLs
|
|
44
41
|
|
package/lib/index.js
CHANGED
package/lib/v4/descriptors.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Descriptors magic objects library.
|
|
3
|
+
* @module @lumjs/compat/v4/descriptors
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
const core = require('@lumjs/core');
|
|
2
7
|
const {InternalObjectId,Enum,types} = core;
|
|
3
|
-
const {doesDescriptor,isObj,
|
|
8
|
+
const {doesDescriptor,isObj,def,B,F,N} = types;
|
|
4
9
|
|
|
5
10
|
// We moved getProperty() to the `@lumjs/core/obj` module.
|
|
6
11
|
const getProperty = core.obj.getProperty;
|
|
@@ -14,6 +19,7 @@ const DESC_ADD = Enum(['ONE', 'SHORT', 'SET'], {flags: true});
|
|
|
14
19
|
* @param {object} desc - Descriptor template.
|
|
15
20
|
* @param {object} [opts] - Options (to be documented.)
|
|
16
21
|
* @returns {object} `desc`
|
|
22
|
+
* @alias module:@lumjs/compat/v4/descriptors.descriptor
|
|
17
23
|
*/
|
|
18
24
|
function descriptor(desc, opts={})
|
|
19
25
|
{
|
|
@@ -177,6 +183,7 @@ exports.descriptor = descriptor;
|
|
|
177
183
|
* Get a Descriptor object.
|
|
178
184
|
* @param {object} desc - Either a Descriptor, or a descriptor template.
|
|
179
185
|
* @returns {object}
|
|
186
|
+
* @alias module:@lumjs/compat/v4/descriptors.getDescriptor
|
|
180
187
|
*/
|
|
181
188
|
function getDescriptor(desc)
|
|
182
189
|
{
|
|
@@ -187,6 +194,7 @@ exports.getDescriptor = getDescriptor;
|
|
|
187
194
|
|
|
188
195
|
/**
|
|
189
196
|
* A factory for building magic Descriptor objects.
|
|
197
|
+
* @alias module:@lumjs/compat/v4/descriptors.DESC
|
|
190
198
|
*/
|
|
191
199
|
const DESC =
|
|
192
200
|
{
|
|
@@ -207,4 +215,3 @@ def(DESC)
|
|
|
207
215
|
('ADD', DESC_ADD);
|
|
208
216
|
|
|
209
217
|
exports.DESC = DESC;
|
|
210
|
-
|
package/lib/v4/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lum.js v4 compatibility set.
|
|
3
|
+
*
|
|
4
|
+
* Now uses lazy-loading for all properties.
|
|
5
|
+
*
|
|
6
|
+
* @module @lumjs/compat/v4
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const {can,from} = require('@lumjs/core').buildModule(module);
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @name module:@lumjs/compat/v4.descriptors
|
|
13
|
+
* @see module:@lumjs/compat/v4/descriptors
|
|
14
|
+
*/
|
|
15
|
+
can('descriptors');
|
|
16
|
+
//exports.descriptors = require('./descriptors');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @name module:@lumjs/compat/v4.DESC
|
|
20
|
+
* @see module:@lumjs/compat/v4/descriptors.DESC
|
|
21
|
+
*/
|
|
22
|
+
from('descriptors', true, 'DESC');
|
|
23
|
+
//exports.DESC = exports.descriptors.DESC;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @name module:@lumjs/compat/v4.prop
|
|
27
|
+
* @see module:@lumjs/compat/v4/prop
|
|
28
|
+
*/
|
|
29
|
+
can('prop');
|
|
30
|
+
//exports.prop = require('./prop');
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @name module:@lumjs/compat/v4.deprecated
|
|
34
|
+
* @see module:@lumjs/compat/v4/deprecated
|
|
35
|
+
*/
|
|
36
|
+
can('deprecated');
|
|
37
|
+
//exports.deprecated = require('./deprecated');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @name module:@lumjs/compat/v4.LoadTracker
|
|
41
|
+
* @see module:@lumjs/compat/v4/loadtracker
|
|
42
|
+
*/
|
|
43
|
+
can('LoadTracker', {module: './loadtracker'});
|
|
44
|
+
//exports.LoadTracker = require('./loadtracker');
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @name module:@lumjs/compat/v4.Promise
|
|
48
|
+
* @see module:@lumjs/compat/v4/promise
|
|
49
|
+
*/
|
|
50
|
+
can('Promise', {module: './promise'});
|
|
51
|
+
//exports.Promise = require('./promise');
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @name module:@lumjs/compat/v4.obj
|
|
55
|
+
* @see module:@lumjs/compat/v4/object-helpers
|
|
56
|
+
*/
|
|
57
|
+
can('obj', {module: './object-helpers'});
|
|
58
|
+
//exports.obj = require('./object-helpers');
|
package/lib/v4/loadtracker.js
CHANGED
|
@@ -13,7 +13,7 @@ const {F,S,B,needObj,needType,def} = core.types
|
|
|
13
13
|
* test which simply see's if the `loadTracker.mark()`
|
|
14
14
|
* method has been called for the specified name.
|
|
15
15
|
*
|
|
16
|
-
* @
|
|
16
|
+
* @exports module:@lumjs/compat/v4/loadtracker
|
|
17
17
|
*/
|
|
18
18
|
class LoadTracker
|
|
19
19
|
{
|
package/lib/v4/object-helpers.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object helpers module
|
|
3
|
+
* @module @lumjs/compat/v4/object-helpers
|
|
4
|
+
*/
|
|
5
|
+
|
|
1
6
|
const core = require('@lumjs/core');
|
|
2
7
|
const {O,F,S,B,isObj} = core.types;
|
|
3
8
|
const {clone,copyProps} = core.obj;
|
|
@@ -18,8 +23,6 @@ const {clone,copyProps} = core.obj;
|
|
|
18
23
|
* @param {...*} sources - The source traits we want to mix in.
|
|
19
24
|
*
|
|
20
25
|
* @return {object|function} The `target` will be returned.
|
|
21
|
-
*
|
|
22
|
-
* @alias module:@lumjs/compat/v4/object-helpers.mixin
|
|
23
26
|
*/
|
|
24
27
|
exports.mixin = function (target, ...inSources)
|
|
25
28
|
{
|
|
@@ -94,8 +97,6 @@ exports.mixin = function (target, ...inSources)
|
|
|
94
97
|
* Anything else will be invalid and will throw an Error.
|
|
95
98
|
*
|
|
96
99
|
* @return {object|function} The `target` will be returned.
|
|
97
|
-
*
|
|
98
|
-
* @method Lum.obj.into
|
|
99
100
|
*/
|
|
100
101
|
exports.into = function (target, ...sources)
|
|
101
102
|
{
|
|
@@ -151,26 +152,28 @@ exports.into = function (target, ...sources)
|
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
/**
|
|
154
|
-
* Clone a simple object, using the
|
|
155
|
+
* Clone a simple object, using the `@lumjs/core/obj.clone` function.
|
|
155
156
|
*
|
|
156
|
-
* By default it uses `
|
|
157
|
+
* By default it uses `CLONE.JSON` mode for cloning, but this can
|
|
157
158
|
* be adjusted as desired by passing a `cloneOpts.mode` option.
|
|
158
159
|
*
|
|
159
160
|
* Can also clone extended properties that aren't serialized in JSON.
|
|
160
161
|
*
|
|
161
162
|
* @param {object} object The object or function to clone.
|
|
162
163
|
*
|
|
163
|
-
* @param {object} [copyProperties] Use
|
|
164
|
+
* @param {(boolean|object)} [copyProperties] Use `copyProps()` as well.
|
|
164
165
|
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
166
|
+
* After the regular cloning process, call `@lumjs/core/obj.copyProps()`.
|
|
167
|
+
* If this is an `object`, then it's the options for `copyProps()`.
|
|
168
|
+
* In the current codebase, this value is assigned as `cloneOpts.copy` as
|
|
169
|
+
* the actual code to call `copyProps()` was moved to the upstream core
|
|
170
|
+
* `clone()` function a while ago.
|
|
167
171
|
*
|
|
168
|
-
* @param {object} [cloneOpts] Options
|
|
172
|
+
* @param {object} [cloneOpts] Options for the core `clone()`.
|
|
169
173
|
*
|
|
170
|
-
* This can be any options supported by the
|
|
174
|
+
* This can be any options supported by the core `clone()` function.
|
|
171
175
|
*
|
|
172
176
|
* @return {object} A clone of the object.
|
|
173
|
-
*
|
|
174
177
|
*/
|
|
175
178
|
exports.clone = function(object, copyProperties, cloneOpts)
|
|
176
179
|
{
|
package/lib/v4/promise.js
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
const {B,O,F} = require('@lumjs/core').types;
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Build a *Promise* object with *Deferred* compatibility.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* @param {(object|boolean)} [options] Options for the `Promise` object.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* If options is a `boolean`, it's assumed to be the `jquery` option.
|
|
9
|
+
*
|
|
10
|
+
* @param {boolean} [options.jquery] Use `jQuery.Deferred` API?
|
|
11
|
+
* - If `true`, use `this._extendJQuery(options)` to define methods.
|
|
12
|
+
* - If `false`, use `this._extendInternal(options)` to define methods.
|
|
9
13
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* @exports module:@lumjs/compat/v4/promise
|
|
15
|
+
* @deprecated Use the Javascript `Promise` object directly.
|
|
16
|
+
*
|
|
17
|
+
* If you need compatibility with the `jQuery.Deferred` API,
|
|
18
|
+
* just use the `jQuery.Deferred` API itself.
|
|
19
|
+
*
|
|
20
|
+
* If you need the `deferDone` or `deferFail` methods, use
|
|
21
|
+
* this until the `@lumjs/defer` library is released.
|
|
18
22
|
*/
|
|
19
23
|
function LumPromise(options)
|
|
20
24
|
{
|
|
@@ -43,6 +47,8 @@ const lpp = LumPromise.prototype;
|
|
|
43
47
|
* Add the methods from jQuery.Deferred to ourself.
|
|
44
48
|
*
|
|
45
49
|
* If jQuery is not loaded, this will throw an error.
|
|
50
|
+
*
|
|
51
|
+
* @alias module:@lumjs/compat/v4/promise#_extendJQuery
|
|
46
52
|
*/
|
|
47
53
|
lpp._extendJQuery = function (options)
|
|
48
54
|
{
|
|
@@ -66,6 +72,7 @@ lpp._extendJQuery = function (options)
|
|
|
66
72
|
* Targetted triggers: resolveWith(), rejectWith(), notifyWith()
|
|
67
73
|
* Info: state()
|
|
68
74
|
*
|
|
75
|
+
* @alias module:@lumjs/compat/v4/promise#_extendInternal
|
|
69
76
|
*/
|
|
70
77
|
lpp._extendInternal = function (options)
|
|
71
78
|
{
|
|
@@ -334,7 +341,7 @@ lpp._extendInternal = function (options)
|
|
|
334
341
|
{
|
|
335
342
|
return state;
|
|
336
343
|
}
|
|
337
|
-
}
|
|
344
|
+
} // _extendInternal()
|
|
338
345
|
|
|
339
346
|
/**
|
|
340
347
|
* Execute a delayed 'done' action.
|
|
@@ -343,6 +350,8 @@ lpp._extendInternal = function (options)
|
|
|
343
350
|
* @param str ts The textStatus to send to done().
|
|
344
351
|
* @param mixed xhr Object to use as XHR (default is this.)
|
|
345
352
|
* @param int timeout The timeout (in ms) defaults to 5.
|
|
353
|
+
*
|
|
354
|
+
* @alias module:@lumjs/compat/v4/promise#deferDone
|
|
346
355
|
*/
|
|
347
356
|
lpp.deferDone = function (obj, ts, xhr, timeout)
|
|
348
357
|
{
|
|
@@ -364,6 +373,8 @@ lpp.deferDone = function (obj, ts, xhr, timeout)
|
|
|
364
373
|
* @param str ts The textStatus to send to fail().
|
|
365
374
|
* @param mixed xhr Object to use as XHR (default is this.)
|
|
366
375
|
* @param int timeout The timeout (in ms) defaults to 5.
|
|
376
|
+
*
|
|
377
|
+
* @alias module:@lumjs/compat/v4/promise#deferFail
|
|
367
378
|
*/
|
|
368
379
|
lpp.deferFail = function (error, ts, xhr, timeout)
|
|
369
380
|
{
|
package/lib/v4/prop.js
CHANGED
|
@@ -74,7 +74,7 @@ const {DESC,getDescriptor} = require('./descriptors');
|
|
|
74
74
|
* a few bonus features I need to document that aren't supported by
|
|
75
75
|
* the otherwise equivalent `def(object,property,descriptor)` call.
|
|
76
76
|
*
|
|
77
|
-
* @
|
|
77
|
+
* @exports module:@lumjs/compat/v4/prop
|
|
78
78
|
* @deprecated Replaced by `@lumjs/core.def` method.
|
|
79
79
|
*/
|
|
80
80
|
function prop(obj, name, arg1, arg2, arg3)
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumjs/compat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/index.js",
|
|
7
|
-
"./v4-meta": "./lib/v4/
|
|
7
|
+
"./v4-meta": "./lib/v4/index.js",
|
|
8
|
+
"./v4": "./lib/v4/index.js",
|
|
9
|
+
"./v4/meta": "./lib/v4/index.js",
|
|
8
10
|
"./v4/*": "./lib/v4/*.js",
|
|
9
11
|
"./package.json": "./package.json"
|
|
10
12
|
},
|
|
@@ -14,7 +16,7 @@
|
|
|
14
16
|
"url": "https://github.com/supernovus/lum.compat.js.git"
|
|
15
17
|
},
|
|
16
18
|
"dependencies": {
|
|
17
|
-
"@lumjs/core": "^1.1
|
|
19
|
+
"@lumjs/core": "^1.6.1",
|
|
18
20
|
"semver": "^7.3.7"
|
|
19
21
|
},
|
|
20
22
|
"scripts":
|
package/lib/v4/meta.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lum.js v4 Meta-Programming helpers.
|
|
3
|
-
* @module @lumjs/compat/v4-meta
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Descriptors magic objects module.
|
|
8
|
-
*/
|
|
9
|
-
exports.descriptors = require('./descriptors');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The `prop()` function.
|
|
13
|
-
*/
|
|
14
|
-
exports.prop = require('./prop');
|