@makano/rew 1.5.5 → 1.5.8

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, typef } = require('../functions/types');
9
- const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry, getters, setters, deepMerge } = require('../functions/core');
9
+ const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry, getters, setters, deepMerge, randFrom, pickRandom } = 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');
@@ -64,4 +64,7 @@ module.exports = {
64
64
  print,
65
65
  printf,
66
66
  input,
67
+
68
+ randFrom,
69
+ pickRandom
67
70
  };
@@ -114,7 +114,23 @@ function setters(object, setters) {
114
114
  configurable: true
115
115
  });
116
116
  }
117
- }
117
+ }
118
+ }
119
+
120
+ function withOut(object, ...keys){
121
+ let o = {...object};
122
+ for(let key of keys) delete o[key];
123
+ return o;
124
+ }
125
+
126
+ function randFrom(min,max) {
127
+ return Math.floor(Math.random()*(max-min+1)+min);
128
+ }
129
+
130
+ function pickRandom(...stuff){
131
+ return stuff[
132
+ randFrom(0, stuff.length - 1)
133
+ ];
118
134
  }
119
135
 
120
136
  module.exports = {
@@ -129,5 +145,8 @@ module.exports = {
129
145
  compose,
130
146
  curry,
131
147
  getters,
132
- setters
148
+ setters,
149
+ withOut,
150
+ randFrom,
151
+ pickRandom
133
152
  };
@@ -10,7 +10,7 @@ module.exports.curl = function curl(options, url){
10
10
  if(options.url && !url){
11
11
  url = options.url
12
12
  }
13
- const method = options.x || "GET";
13
+ const method = options.x || options.method || "GET";
14
14
  const f = future.promise(fetch(url, {
15
15
  ...options,
16
16
  method
@@ -41,7 +41,7 @@ const lookUpInOtherApps = (fullPath) => {
41
41
  };
42
42
 
43
43
  module.exports.imp = function (runPath, context) {
44
- return function (filename, options = {}) {
44
+ return function (filename, options = {}, defaultMode) {
45
45
  if (!options) options = {};
46
46
  if(filename == 'std' || filename == '#std') return {};
47
47
  let type = options.type ? options.type : filename.endsWith('.coffee') ? 'coffee' : (
@@ -168,6 +168,9 @@ module.exports.imp = function (runPath, context) {
168
168
  /**/ if(options.mock === null) return null;
169
169
  //**
170
170
 
171
+ //** Return defaults
172
+ /**/ if(defaultMode !== true && exports?.default) exports = exports.default;
173
+
171
174
  return exports;
172
175
  };
173
176
  };
@@ -1,4 +1,5 @@
1
1
  const jsYaml = require("js-yaml");
2
+ const { yamlFile } = require("../modules/yaml");
2
3
 
3
4
 
4
5
 
@@ -11,8 +12,11 @@ function jsons(thing){
11
12
  }
12
13
 
13
14
 
14
- function yaml(thing){
15
- return jsYaml.loadAll(thing)[0];
15
+ function yaml(thing, ...schema){
16
+ return yamlFile({
17
+ content: thing,
18
+ path: ''
19
+ }, schema);
16
20
  }
17
21
 
18
22
  function yamls(thing){