@makano/rew 1.2.72 → 1.2.74

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,24 @@ module.exports.Usage = class Usage {
28
28
  create(name, trigger, save = true){
29
29
  return new Usage(name, trigger, save);
30
30
  }
31
+
32
+ group(...group){
33
+ return new Usage.Group(group, {});
34
+ }
35
+
36
+ static Group = class UsageGroup {
37
+ g = []
38
+ constructor(g, props = {}){
39
+ this.g = g;
40
+ if(props) for(let i in props){
41
+ this[i] = props[i];
42
+ }
43
+ }
44
+
45
+ with(props){
46
+ return new UsageGroup(this.g, props);
47
+ }
48
+ }
31
49
  }
32
50
 
33
51
  class Namespace extends module.exports.Usage {
@@ -43,15 +61,7 @@ class Namespace extends module.exports.Usage {
43
61
  this.namespace = ns;
44
62
  }
45
63
 
46
- static Group = class NamespaceGroup {
47
- g = [{}, () => {}]
48
- constructor(g, props){
49
- this.g = g;
50
- for(let i in props){
51
- this[i] = props[i];
52
- }
53
- }
54
- }
64
+ static Group = class NamespaceGroup extends module.exports.Usage.Group {}
55
65
  }
56
66
  module.exports.Namespace = Namespace;
57
67
 
@@ -106,6 +106,10 @@ module.exports.prepareContext = function (
106
106
  context.exports = exportsFunction(context);
107
107
 
108
108
  context.using = (name, ...params) => {
109
+ if(name instanceof Usage.Group){
110
+ params.unshift(...name.g.slice(1));
111
+ name = name.g[0];
112
+ }
109
113
  if(USING_DEFAULT[name]){
110
114
  if(USING_DEFAULT[name].param) {
111
115
  context.__using__[name] = USING_DEFAULT[name].param(...params);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@makano/rew",
3
- "version": "1.2.72",
3
+ "version": "1.2.74",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {
package/runtime.d.ts CHANGED
@@ -944,7 +944,7 @@ declare function clear(): void;
944
944
 
945
945
  declare function namespace(object: any, callback: () => any): Usage;
946
946
  declare namespace namespace {
947
- function group<T = any[], U = any>(group: T, props?: U): { g: T }
947
+ function group<T = any[], U = any>(group: T, props?: U): { g: T, [key: string]: any }
948
948
  }
949
949
 
950
950
  declare class Usage<T = () => void> {
@@ -953,4 +953,5 @@ declare class Usage<T = () => void> {
953
953
  save: boolean;
954
954
  constructor(name: string, trigger: T, save: boolean);
955
955
  create(name: string, trigger: T, save: boolean): Usage;
956
+ group(...group: any[]): { g: T, with: (props: any) => { g: T, [key: string]: any }, [key: string]: any }
956
957
  }