@makano/rew 1.2.71 → 1.2.73

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.
@@ -28,19 +28,41 @@ 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, props){
33
+ return new Usage.Group(group, props);
34
+ }
35
+
36
+ static Group = class UsageGroup {
37
+ g = [{}, () => {}]
38
+ constructor(g, props){
39
+ this.g = g;
40
+ for(let i in props){
41
+ this[i] = props[i];
42
+ }
43
+ }
44
+ }
31
45
  }
32
46
 
33
47
  class Namespace extends module.exports.Usage {
34
48
  namespace = {};
35
49
  constructor(ns, cb){
36
50
  super('namespace');
51
+ if(ns instanceof Namespace.Group){
52
+ cb = ns.g[1]
53
+ ns = ns.g[0]
54
+ }
37
55
  this.save = false;
38
56
  this.trigger = cb;
39
57
  this.namespace = ns;
40
58
  }
59
+
60
+ static Group = class NamespaceGroup extends module.exports.Usage.Group {}
41
61
  }
42
62
  module.exports.Namespace = Namespace;
43
63
 
44
64
  module.exports.namespace = (namespace, cb) => {
45
65
  return new Namespace(namespace, cb);
46
- }
66
+ }
67
+
68
+ module.exports.namespace.group = (group, props) => new Namespace.Group(group, props);
@@ -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[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.71",
3
+ "version": "1.2.73",
4
4
  "description": "A simple coffescript runtime and app manager",
5
5
  "main": "main.js",
6
6
  "directories": {
package/runtime.d.ts CHANGED
@@ -943,6 +943,9 @@ declare function wait(fn: CallableFunction, ...args: any[]): any;
943
943
  declare function clear(): void;
944
944
 
945
945
  declare function namespace(object: any, callback: () => any): Usage;
946
+ declare namespace namespace {
947
+ function group<T = any[], U = any>(group: T, props?: U): { g: T, [key: string]: any }
948
+ }
946
949
 
947
950
  declare class Usage<T = () => void> {
948
951
  name: string;
@@ -950,4 +953,5 @@ declare class Usage<T = () => void> {
950
953
  save: boolean;
951
954
  constructor(name: string, trigger: T, save: boolean);
952
955
  create(name: string, trigger: T, save: boolean): Usage;
956
+ group<T = any[], U = any>(group: T, props?: U): { g: T, [key: string]: any }
953
957
  }