@javish/lib 0.2.1 → 0.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/changes.md +14 -2
- package/index.js +21 -2
- package/package.json +4 -1
package/changes.md
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
+
## 30 jan 2026
|
|
2
|
+
|
|
3
|
+
### version 0.3.0
|
|
4
|
+
|
|
5
|
+
- accept options to the factory (new call) and install them as descriptors on
|
|
6
|
+
the context.
|
|
7
|
+
- fix: handle passed args properly.
|
|
8
|
+
|
|
1
9
|
## 28 jan 2026
|
|
2
10
|
|
|
3
|
-
### version 0.2.
|
|
11
|
+
### version 0.2.2
|
|
12
|
+
|
|
13
|
+
- enable single-argument mode where only implementation is passed without base
|
|
14
|
+
class in which case a dedicated proto is created.
|
|
15
|
+
|
|
16
|
+
### version 0.2.0-0.2.1
|
|
4
17
|
|
|
5
18
|
- export `FnImplFactory` from runtimes to consume to emulate functional
|
|
6
19
|
interfaces.
|
|
7
|
-
s
|
package/index.js
CHANGED
|
@@ -18,6 +18,15 @@
|
|
|
18
18
|
* @param {Record<string,Function>} methods
|
|
19
19
|
*/
|
|
20
20
|
var ImplFactory = function (Base, methods) {
|
|
21
|
+
if(methods == undefined) { // [...arguments.length] == 1
|
|
22
|
+
return function() {
|
|
23
|
+
var proto = Object.create(null)
|
|
24
|
+
var obj = Object.create(proto)
|
|
25
|
+
for (var k in Base) proto[k] = Base[k] // those can be passed to the proxy when creating
|
|
26
|
+
return obj
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
21
30
|
return function () {
|
|
22
31
|
var obj = new Base
|
|
23
32
|
var proto = Object.getPrototypeOf(obj)
|
|
@@ -37,7 +46,7 @@ var ImplFactory = function (Base, methods) {
|
|
|
37
46
|
* @template {Record<string,*>} C
|
|
38
47
|
*/
|
|
39
48
|
module.exports.FnImplFactory = (Base, Impl) => {
|
|
40
|
-
var target = function (__fm, I,
|
|
49
|
+
var target = function (__fm, I, ...args) {
|
|
41
50
|
// var __fm = base.__fm.call(newTarget) // invoke
|
|
42
51
|
// console.log('> 💡 functional #' + I) // if calling .test on this, might want to access base???
|
|
43
52
|
return __fm.apply(this, args)
|
|
@@ -47,13 +56,14 @@ module.exports.FnImplFactory = (Base, Impl) => {
|
|
|
47
56
|
apply:target,
|
|
48
57
|
construct(fn, args, Target) {
|
|
49
58
|
// var I=++i
|
|
59
|
+
|
|
50
60
|
var __fm=Base.prototype.__fm.call(Target.prototype)
|
|
51
61
|
if(!__fm) {
|
|
52
62
|
__fm=Base.prototype.__fm.call(Impl)
|
|
53
63
|
}
|
|
54
64
|
var base=new Base
|
|
55
65
|
// var target=new (Target.prototype.constructor)
|
|
56
|
-
var descs=
|
|
66
|
+
var descs=Object.create(null)
|
|
57
67
|
if(!$fields) {
|
|
58
68
|
$fields = new Set
|
|
59
69
|
var _$fields=Object.entries(Object.getOwnPropertyDescriptors(base))
|
|
@@ -69,6 +79,15 @@ module.exports.FnImplFactory = (Base, Impl) => {
|
|
|
69
79
|
// descs[k]=Object.getOwnPropertyDescriptor(target,k)
|
|
70
80
|
} // what about private fields though
|
|
71
81
|
}
|
|
82
|
+
|
|
83
|
+
for(var cc of args) {
|
|
84
|
+
// in args,there are some kind of options, which could be like come first.
|
|
85
|
+
if(typeof cc == 'object') {
|
|
86
|
+
Object.assign(descs,Object.getOwnPropertyDescriptors(cc))
|
|
87
|
+
}
|
|
88
|
+
// or last as at the moment...
|
|
89
|
+
}
|
|
90
|
+
|
|
72
91
|
var STATE=Object.create(Target.prototype,descs)
|
|
73
92
|
|
|
74
93
|
// if(typeof Target.prototype.constructor=='function') {
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@javish/lib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "British Software",
|
|
6
6
|
"email": "packages+javish@british.software"
|
|
7
|
+
},
|
|
8
|
+
"scripts": {
|
|
9
|
+
"t": "git tag @javish/base-v$(node -p \"require('./package.json').version\") && git push --tags"
|
|
7
10
|
}
|
|
8
11
|
}
|