@makano/rew 1.2.81 → 1.2.83

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.
@@ -6,7 +6,7 @@ const sleep = require('../functions/sleep');
6
6
  const { match } = require('../functions/match');
7
7
  const { map } = require('../functions/map');
8
8
  const { typex, typeis, typedef, typei, int, float, num, str, bool } = require('../functions/types');
9
- const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry } = require('../functions/core');
9
+ const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry, getters, setters } = require('../functions/core');
10
10
  const { print, input, clear, printf } = require('../functions/stdout');
11
11
  const { curl } = require('../functions/curl');
12
12
  const { wait } = require('../functions/wait');
@@ -45,6 +45,8 @@ module.exports = {
45
45
  uniqueId,
46
46
  compose,
47
47
  curry,
48
+ getters,
49
+ setters,
48
50
 
49
51
  json,
50
52
  jsons,
@@ -34,6 +34,19 @@ module.exports.Usage = class Usage {
34
34
  return new Usage.Group(group, {});
35
35
  }
36
36
 
37
+ /**
38
+ *
39
+ * @param {...Usage} usages
40
+ * @returns {any[]}
41
+ */
42
+ merge(...usages){
43
+ return new Usage(usages.map(u => u.name).join('-'), (...args) => {
44
+ return usages.map(u => {
45
+ return u.trigger(...args)
46
+ });
47
+ })
48
+ }
49
+
37
50
  static Group = class UsageGroup {
38
51
  g = []
39
52
  constructor(g, props = {}){
@@ -71,6 +71,30 @@ function curry(fn) {
71
71
  return curried;
72
72
  }
73
73
 
74
+ function getters(object, getters) {
75
+ for (let prop in getters) {
76
+ if (getters.hasOwnProperty(prop) && typeof getters[prop] === 'function') {
77
+ Object.defineProperty(object, prop, {
78
+ get: getters[prop],
79
+ enumerable: true,
80
+ configurable: true
81
+ });
82
+ }
83
+ }
84
+ }
85
+
86
+ function setters(object, setters) {
87
+ for (let prop in setters) {
88
+ if (setters.hasOwnProperty(prop) && typeof setters[prop] === 'function') {
89
+ Object.defineProperty(object, prop, {
90
+ set: setters[prop],
91
+ enumerable: true,
92
+ configurable: true
93
+ });
94
+ }
95
+ }
96
+ }
97
+
74
98
  module.exports = {
75
99
  isEmpty,
76
100
  clone,
@@ -81,4 +105,6 @@ module.exports = {
81
105
  reduce,
82
106
  compose,
83
107
  curry,
108
+ getters,
109
+ setters
84
110
  };
@@ -419,7 +419,7 @@ const cpl = (module.exports.compile = function (file, options = {}) {
419
419
 
420
420
  const babelify = (code, options) => babel.transformSync(code, {
421
421
  presets: [
422
- ...(doJSX ? [[babelReact, { pragmaFrag: options.jsxPragmaFrag || execOptions.jsxPragmaFrag, pragma: options.jsxPragma || execOptions.jsxPragma }]] : [])
422
+ ...(doJSX ? [[babelReact, { throwIfNamespace: false, pragmaFrag: options.jsxPragmaFrag || execOptions.jsxPragmaFrag, pragma: options.jsxPragma || execOptions.jsxPragma }]] : [])
423
423
  ],
424
424
  plugins: [
425
425
  ...(doDecorators ? [[require('@babel/plugin-proposal-decorators'), { version: '2023-05' }], [require('@babel/plugin-proposal-class-properties'), { loose: true }], [require('@babel/plugin-transform-class-static-block'), {}]] : [])
@@ -128,10 +128,11 @@ module.exports.prepareContext = function (
128
128
  childContext.parentNamespace = context;
129
129
  const code = `(${trigger.toString()})()`;
130
130
  if(name.onUse) name.onUse();
131
- runtime.exec(code, childContext, code, context.module.filepath);
131
+ return runtime.exec(code, childContext, code, context.module.filepath);
132
132
  } else if(name instanceof Usage) {
133
133
  const v = name.trigger(...params) || true;
134
134
  if(name.save !== false) context.__using__[name.name] = v;
135
+ return v;
135
136
  } else {
136
137
  context.__using__[name] = params.length ? params.length > 1 ? [...params] : params : true;
137
138
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.81",
3
+ "version": "1.2.83",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {