@makano/rew 1.1.8 → 1.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/lib/coffeescript/browser.js +144 -139
  2. package/lib/coffeescript/cake.js +132 -133
  3. package/lib/coffeescript/coffeescript.js +437 -381
  4. package/lib/coffeescript/command.js +806 -724
  5. package/lib/coffeescript/grammar.js +1908 -2474
  6. package/lib/coffeescript/helpers.js +509 -473
  7. package/lib/coffeescript/index.js +228 -215
  8. package/lib/coffeescript/lexer.js +2282 -1909
  9. package/lib/coffeescript/nodes.js +9782 -9202
  10. package/lib/coffeescript/optparse.js +255 -227
  11. package/lib/coffeescript/parser.js +20305 -1265
  12. package/lib/coffeescript/register.js +107 -87
  13. package/lib/coffeescript/repl.js +307 -284
  14. package/lib/coffeescript/rewriter.js +1389 -1079
  15. package/lib/coffeescript/scope.js +176 -172
  16. package/lib/coffeescript/sourcemap.js +242 -227
  17. package/lib/rew/cli/cli.js +243 -202
  18. package/lib/rew/cli/log.js +31 -32
  19. package/lib/rew/cli/run.js +10 -12
  20. package/lib/rew/cli/utils.js +248 -176
  21. package/lib/rew/const/config_path.js +2 -3
  22. package/lib/rew/const/default.js +38 -35
  23. package/lib/rew/const/files.js +9 -9
  24. package/lib/rew/const/opt.js +8 -8
  25. package/lib/rew/css/theme.css +2 -2
  26. package/lib/rew/functions/core.js +55 -57
  27. package/lib/rew/functions/curl.js +23 -0
  28. package/lib/rew/functions/emitter.js +52 -55
  29. package/lib/rew/functions/exec.js +25 -21
  30. package/lib/rew/functions/export.js +18 -20
  31. package/lib/rew/functions/fs.js +55 -54
  32. package/lib/rew/functions/future.js +29 -21
  33. package/lib/rew/functions/id.js +8 -9
  34. package/lib/rew/functions/import.js +116 -110
  35. package/lib/rew/functions/map.js +13 -16
  36. package/lib/rew/functions/match.js +35 -26
  37. package/lib/rew/functions/path.js +8 -8
  38. package/lib/rew/functions/require.js +32 -33
  39. package/lib/rew/functions/sleep.js +2 -2
  40. package/lib/rew/functions/stdout.js +20 -20
  41. package/lib/rew/functions/types.js +96 -95
  42. package/lib/rew/html/ui.html +12 -13
  43. package/lib/rew/html/ui.js +205 -168
  44. package/lib/rew/main.js +14 -14
  45. package/lib/rew/misc/findAppInfo.js +14 -14
  46. package/lib/rew/misc/findAppPath.js +16 -16
  47. package/lib/rew/misc/seededid.js +9 -11
  48. package/lib/rew/models/enum.js +12 -12
  49. package/lib/rew/models/struct.js +30 -32
  50. package/lib/rew/modules/compiler.js +228 -177
  51. package/lib/rew/modules/context.js +33 -21
  52. package/lib/rew/modules/fs.js +10 -10
  53. package/lib/rew/modules/runtime.js +17 -21
  54. package/lib/rew/modules/yaml.js +27 -30
  55. package/lib/rew/pkgs/conf.js +80 -80
  56. package/lib/rew/pkgs/data.js +12 -7
  57. package/lib/rew/pkgs/date.js +27 -28
  58. package/lib/rew/pkgs/env.js +6 -8
  59. package/lib/rew/pkgs/modules/data/bintree.js +52 -52
  60. package/lib/rew/pkgs/modules/data/doublylinked.js +85 -85
  61. package/lib/rew/pkgs/modules/data/linkedList.js +73 -73
  62. package/lib/rew/pkgs/modules/data/queue.js +19 -20
  63. package/lib/rew/pkgs/modules/data/stack.js +19 -19
  64. package/lib/rew/pkgs/modules/threads/worker.js +36 -26
  65. package/lib/rew/pkgs/modules/ui/classes.js +182 -178
  66. package/lib/rew/pkgs/pkgs.js +9 -10
  67. package/lib/rew/pkgs/rune.js +391 -345
  68. package/lib/rew/pkgs/threads.js +57 -53
  69. package/lib/rew/pkgs/ui.js +148 -136
  70. package/package.json +1 -1
@@ -3,30 +3,30 @@ const { execOptions } = require("../const/opt");
3
3
  const { exportsFunction, pubFunction } = require("../functions/export");
4
4
  const { imp } = require("../functions/import");
5
5
  const { customRequire } = require("../functions/require");
6
- const fsLib = require('../functions/fs');
7
- const pathLib = require('../functions/path');
8
- const execLib = require('../functions/exec');
6
+ const fsLib = require("../functions/fs");
7
+ const pathLib = require("../functions/path");
8
+ const execLib = require("../functions/exec");
9
9
  const { findAppInfo } = require("../misc/findAppInfo");
10
10
 
11
11
  let mainFile = "";
12
- const isMainFile = filepath => filepath == mainFile;
12
+ const isMainFile = (filepath) => filepath == mainFile;
13
13
  module.exports.prepareContext = function (
14
14
  custom_context,
15
15
  options,
16
16
  filepath = "",
17
17
  runPath = () => {},
18
18
  ) {
19
- if(mainFile == "") mainFile = filepath;
19
+ if (mainFile == "") mainFile = filepath;
20
20
  let context = {
21
21
  module: {
22
22
  exports: null,
23
23
  filepath,
24
24
  main: isMainFile(filepath),
25
- imports: []
25
+ imports: [],
26
26
  },
27
27
  imports: {
28
28
  meta: {},
29
- assert: options.import ?? {}
29
+ assert: options.import ?? {},
30
30
  },
31
31
  app: findAppInfo(filepath),
32
32
  ...fsLib(filepath),
@@ -34,7 +34,7 @@ module.exports.prepareContext = function (
34
34
  if (options.useContext) {
35
35
  context = {
36
36
  ...custom_context,
37
- ...context
37
+ ...context,
38
38
  };
39
39
  } else {
40
40
  context = {
@@ -44,9 +44,15 @@ module.exports.prepareContext = function (
44
44
  ...execLib(filepath),
45
45
  require: (package) => {
46
46
  try {
47
- return execOptions.nativeRequire || package.startsWith('node:') ? require(package.startsWith('node:') ? package.split('node:')[1] : package) : customRequire(package, filepath);
47
+ return execOptions.nativeRequire || package.startsWith("node:")
48
+ ? require(
49
+ package.startsWith("node:")
50
+ ? package.split("node:")[1]
51
+ : package,
52
+ )
53
+ : customRequire(package, filepath);
48
54
  } catch (e) {
49
- throw new Error("Module "+package+" not found");
55
+ throw new Error("Module " + package + " not found");
50
56
  }
51
57
  },
52
58
  ...custom_context,
@@ -58,34 +64,40 @@ module.exports.prepareContext = function (
58
64
  target: {
59
65
  on: (event, listener) => process.on(event, listener),
60
66
  off: (event, listener) => process.off(event, listener),
61
- emit: (event, code) => process.emit(event, code)
67
+ emit: (event, code) => process.emit(event, code),
62
68
  },
63
69
  env: process.env,
64
70
  cwd: () => process.cwd(),
65
- arch: process.arch
71
+ arch: process.arch,
66
72
  };
67
-
73
+
68
74
  context.global = context;
69
75
  context.imports.assert = options.import ?? {};
70
76
  context.imp = imp(runPath, context);
71
77
  context.inc = (package, asserts) => {
72
- try{
73
- if(package.startsWith('node:') || package.startsWith('pkg:')) throw new Error('');
78
+ try {
79
+ if (package.startsWith("node:") || package.startsWith("pkg:"))
80
+ throw new Error("");
74
81
  return context.imp(package, asserts);
75
- } catch(e) {
76
- return context.require(package.startsWith('pkg:') ? package.split('pkg:')[1] : package);
82
+ } catch (e) {
83
+ return context.require(
84
+ package.startsWith("pkg:") ? package.split("pkg:")[1] : package,
85
+ );
77
86
  }
78
87
  };
79
88
  context.pub = pubFunction(context);
80
89
  context.exports = exportsFunction(context);
81
90
 
82
- if(context.module.main || (options.fromMain == true && options.as == 'main')){
91
+ if (
92
+ context.module.main ||
93
+ (options.fromMain == true && options.as == "main")
94
+ ) {
83
95
  context.opt = {
84
- set: (key, value) => execOptions[key] = value,
96
+ set: (key, value) => (execOptions[key] = value),
85
97
  get: (key) => execOptions[key],
86
98
  push: (key, value) => execOptions[key]?.push(value),
87
- pop: (key) => execOptions[key]?.pop()
99
+ pop: (key) => execOptions[key]?.pop(),
88
100
  };
89
- } else delete context.opt
101
+ } else delete context.opt;
90
102
  return context;
91
103
  };
@@ -1,19 +1,19 @@
1
- const { struct } = require("../models/struct");
2
- const fs = require("fs");
1
+ const { struct } = require('../models/struct');
2
+ const fs = require('fs');
3
3
 
4
4
  const file = (module.exports.file = struct({
5
- path: "",
6
- content: "",
5
+ path: '',
6
+ content: '',
7
7
  }));
8
8
 
9
9
  const readFile = (module.exports.readFile = function readFile(file) {
10
- return (file.content = fs.readFileSync(file.path, { encoding: "utf-8" }));
10
+ return (file.content = fs.readFileSync(file.path, { encoding: 'utf-8' }));
11
11
  });
12
12
 
13
13
  module.exports.getFile = function (filepath) {
14
- const f = file({
15
- path: filepath,
16
- });
17
- readFile(f);
18
- return f;
14
+ const f = file({
15
+ path: filepath,
16
+ });
17
+ readFile(f);
18
+ return f;
19
19
  };
@@ -1,28 +1,24 @@
1
- const vm = require("vm");
2
- const { compileFile } = require("./compiler");
3
- const { prepareContext } = require("./context");
1
+ const vm = require('vm');
2
+ const { compileFile } = require('./compiler');
3
+ const { prepareContext } = require('./context');
4
4
 
5
5
  const exec = (module.exports.exec = function (code, context) {
6
- return vm.runInNewContext(code, vm.createContext(context), {
7
- filename: context.module.filepath,
8
- lineOffset: 0,
9
- displayErrors: true
10
- });
6
+ return vm.runInNewContext(code, vm.createContext(context), {
7
+ filename: context.module.filepath,
8
+ lineOffset: 0,
9
+ displayErrors: true,
10
+ });
11
11
  });
12
12
 
13
- module.exports.runPath = function runPath(
14
- filepath,
15
- options = {},
16
- custom_context = {},
17
- ) {
18
- const { compiled_code, file } = compileFile(filepath, options);
19
- const context = prepareContext(custom_context, options, file.path, runPath);
13
+ module.exports.runPath = function runPath(filepath, options = {}, custom_context = {}) {
14
+ const { compiled_code, file } = compileFile(filepath, options);
15
+ const context = prepareContext(custom_context, options, file.path, runPath);
20
16
 
21
- context.module.compiled = compiled_code;
22
- context.process.exit = (int) => process.exit(int);
17
+ context.module.compiled = compiled_code;
18
+ context.process.exit = (int) => process.exit(int);
23
19
 
24
- return {
25
- context,
26
- returns: exec(compiled_code, context),
27
- };
20
+ return {
21
+ context,
22
+ returns: exec(compiled_code, context),
23
+ };
28
24
  };
@@ -1,36 +1,33 @@
1
- const yaml = require("js-yaml");
2
- const path = require("path");
3
- const { getFile } = require("./fs");
1
+ const yaml = require('js-yaml');
2
+ const path = require('path');
3
+ const { getFile } = require('./fs');
4
4
 
5
5
  function yamlFile(file) {
6
- const schema = new yaml.Schema([
7
- new yaml.Type("!import", {
8
- kind: "scalar",
9
- construct: (p) => importYaml(path.resolve(path.dirname(file.path), p)),
10
- }),
11
- new yaml.Type("!int", {
12
- kind: "scalar",
13
- construct: (data) => parseInt(data),
14
- }),
15
- new yaml.Type("!float", {
16
- kind: "scalar",
17
- construct: (data) => parseFloat(data),
18
- }),
19
- new yaml.Type("!bool", {
20
- kind: "scalar",
21
- construct: (data) => (data == "true" ? true : false),
22
- }),
23
- ]);
6
+ const schema = new yaml.Schema([
7
+ new yaml.Type('!import', {
8
+ kind: 'scalar',
9
+ construct: (p) => importYaml(path.resolve(path.dirname(file.path), p)),
10
+ }),
11
+ new yaml.Type('!int', {
12
+ kind: 'scalar',
13
+ construct: (data) => parseInt(data),
14
+ }),
15
+ new yaml.Type('!float', {
16
+ kind: 'scalar',
17
+ construct: (data) => parseFloat(data),
18
+ }),
19
+ new yaml.Type('!bool', {
20
+ kind: 'scalar',
21
+ construct: (data) => (data == 'true' ? true : false),
22
+ }),
23
+ ]);
24
24
 
25
- return yaml.load(file.content, { schema });
25
+ return yaml.load(file.content, { schema });
26
26
  }
27
27
 
28
- const importYaml = (module.exports.importYaml = function importYaml(
29
- filepath,
30
- file,
31
- ) {
32
- if (!file) {
33
- file = getFile(filepath);
34
- }
35
- return yamlFile(file);
28
+ const importYaml = (module.exports.importYaml = function importYaml(filepath, file) {
29
+ if (!file) {
30
+ file = getFile(filepath);
31
+ }
32
+ return yamlFile(file);
36
33
  });
@@ -5,95 +5,95 @@ const { CONFIG_PATH } = require('../const/config_path');
5
5
  const { seededID } = require('../misc/seededid');
6
6
 
7
7
  const createPackageRoot = (packageName) => {
8
- const rootPath = path.join(CONFIG_PATH, packageName);
9
- fs.mkdirSync(rootPath, { recursive: true });
10
- return rootPath;
11
- }
8
+ const rootPath = path.join(CONFIG_PATH, packageName);
9
+ fs.mkdirSync(rootPath, { recursive: true });
10
+ return rootPath;
11
+ };
12
12
 
13
13
  module.exports = (context) => ({
14
- CONFIG_PATH,
15
- _onImport(){
16
- if(context.app){
17
- return this.create(context.app.config.package);
18
- } else {
19
- return this.create(seededID(path.basename(context.module.filepath).replace(/[-_/\.]/g, '')));
20
- }
21
- },
22
- create: (packageName) => {
23
- const rootPath = createPackageRoot(packageName);
14
+ CONFIG_PATH,
15
+ _onImport() {
16
+ if (context.app) {
17
+ return this.create(context.app.config.package);
18
+ } else {
19
+ return this.create(seededID(path.basename(context.module.filepath).replace(/[-_/\.]/g, '')));
20
+ }
21
+ },
22
+ create: (packageName) => {
23
+ const rootPath = createPackageRoot(packageName);
24
24
 
25
- const conf = {};
25
+ const conf = {};
26
26
 
27
- const dumpYaml = (val) => {
28
- if(JSON.stringify(val) == '{}') return '';
29
- else return jsYaml.dump(val);
30
- }
27
+ const dumpYaml = (val) => {
28
+ if (JSON.stringify(val) == '{}') return '';
29
+ else return jsYaml.dump(val);
30
+ };
31
31
 
32
- const setData = (optionCenter, key, value) => {
33
- conf[optionCenter.name][key] = value;
34
- fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
35
- return true;
36
- }
32
+ const setData = (optionCenter, key, value) => {
33
+ conf[optionCenter.name][key] = value;
34
+ fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
35
+ return true;
36
+ };
37
37
 
38
- const removeData = (optionCenter, key) => {
39
- delete conf[optionCenter.name][key];
40
- fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
41
- return true;
42
- }
38
+ const removeData = (optionCenter, key) => {
39
+ delete conf[optionCenter.name][key];
40
+ fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
41
+ return true;
42
+ };
43
43
 
44
- const getData = (optionCenter, key) => {
45
- return conf[optionCenter.name][key];
46
- }
44
+ const getData = (optionCenter, key) => {
45
+ return conf[optionCenter.name][key];
46
+ };
47
47
 
48
- const staticFile = (name, defaultValue = "") => {
49
- const fileRoot = path.join(rootPath, name);
50
- const exists = fs.existsSync(fileRoot);
51
- return {
52
- create(value){
53
- if(!fs.existsSync(path.dirname(fileRoot))) fs.mkdirSync(path.dirname(fileRoot), { recursive: true });
54
- fs.writeFileSync(fileRoot, value || defaultValue);
55
- },
56
- fileRoot,
57
- exists
58
- }
59
- }
60
-
61
- const createOptionCenter = (name, defaults = {}) => {
62
- const optionRoot = path.join(rootPath, name+'.yaml');
63
- if(!fs.existsSync(path.dirname(optionRoot))) fs.mkdirSync(path.dirname(optionRoot), { recursive: true });
64
- if(!fs.existsSync(optionRoot)) {
65
- conf[name] = defaults;
66
- fs.writeFileSync(optionRoot, dumpYaml(defaults));
67
- } else {
68
- conf[name] = jsYaml.load(fs.readFileSync(optionRoot, { encoding: 'utf-8' }));
69
- }
48
+ const staticFile = (name, defaultValue = '') => {
49
+ const fileRoot = path.join(rootPath, name);
50
+ const exists = fs.existsSync(fileRoot);
51
+ return {
52
+ create(value) {
53
+ if (!fs.existsSync(path.dirname(fileRoot))) fs.mkdirSync(path.dirname(fileRoot), { recursive: true });
54
+ fs.writeFileSync(fileRoot, value || defaultValue);
55
+ },
56
+ fileRoot,
57
+ exists,
58
+ };
59
+ };
70
60
 
71
- const optionCenter = {
72
- root: optionRoot,
73
- name,
74
- package: packageName
75
- }
61
+ const createOptionCenter = (name, defaults = {}) => {
62
+ const optionRoot = path.join(rootPath, name + '.yaml');
63
+ if (!fs.existsSync(path.dirname(optionRoot))) fs.mkdirSync(path.dirname(optionRoot), { recursive: true });
64
+ if (!fs.existsSync(optionRoot)) {
65
+ conf[name] = defaults;
66
+ fs.writeFileSync(optionRoot, dumpYaml(defaults));
67
+ } else {
68
+ conf[name] = jsYaml.load(fs.readFileSync(optionRoot, { encoding: 'utf-8' }));
69
+ }
76
70
 
77
- return {
78
- get: (key) => getData(optionCenter, key),
79
- set: (key, value) => setData(optionCenter, key, value),
80
- remove: (key) => removeData(optionCenter, key),
81
- reset: () => fs.writeFileSync(optionCenter.root, dumpYaml(defaults)) && (conf[name] = defaults),
82
- getAll: (str = false) => str ? dumpYaml(conf[name]) : conf[name],
83
- ...optionCenter
84
- }
85
- }
71
+ const optionCenter = {
72
+ root: optionRoot,
73
+ name,
74
+ package: packageName,
75
+ };
86
76
 
87
- const defaultCenter = createOptionCenter('_default', { default: true });
77
+ return {
78
+ get: (key) => getData(optionCenter, key),
79
+ set: (key, value) => setData(optionCenter, key, value),
80
+ remove: (key) => removeData(optionCenter, key),
81
+ reset: () => fs.writeFileSync(optionCenter.root, dumpYaml(defaults)) && (conf[name] = defaults),
82
+ getAll: (str = false) => (str ? dumpYaml(conf[name]) : conf[name]),
83
+ ...optionCenter,
84
+ };
85
+ };
88
86
 
89
- return {
90
- optionCenter: createOptionCenter,
91
- staticFile: staticFile,
92
- set: (key, value) => defaultCenter.set(key, value),
93
- get: (key) => defaultCenter.get(key),
94
- remove: (key) => defaultCenter.remove(key),
95
- root: rootPath,
96
- package: packageName
97
- }
98
- }
99
- });
87
+ const defaultCenter = createOptionCenter('_default', { default: true });
88
+
89
+ return {
90
+ optionCenter: createOptionCenter,
91
+ staticFile: staticFile,
92
+ set: (key, value) => defaultCenter.set(key, value),
93
+ get: (key) => defaultCenter.get(key),
94
+ remove: (key) => defaultCenter.remove(key),
95
+ root: rootPath,
96
+ package: packageName,
97
+ };
98
+ },
99
+ });
@@ -1,8 +1,13 @@
1
- const { BinaryTree } = require("./modules/data/bintree");
2
- const { DoublyLinkedList } = require("./modules/data/doublylinked");
3
- const { LinkedList } = require("./modules/data/linkedList");
4
- const { Queue } = require("./modules/data/queue");
5
- const { Stack } = require("./modules/data/stack");
1
+ const { BinaryTree } = require('./modules/data/bintree');
2
+ const { DoublyLinkedList } = require('./modules/data/doublylinked');
3
+ const { LinkedList } = require('./modules/data/linkedList');
4
+ const { Queue } = require('./modules/data/queue');
5
+ const { Stack } = require('./modules/data/stack');
6
6
 
7
-
8
- module.exports = (context) => ({ Stack, Queue, BinaryTree, DoublyLinkedList, LinkedList });
7
+ module.exports = (context) => ({
8
+ Stack,
9
+ Queue,
10
+ BinaryTree,
11
+ DoublyLinkedList,
12
+ LinkedList,
13
+ });
@@ -8,10 +8,10 @@
8
8
  * @return {string} - The formatted date string.
9
9
  */
10
10
  function formatDate(date) {
11
- const year = date.getFullYear();
12
- const month = String(date.getMonth() + 1).padStart(2, '0');
13
- const day = String(date.getDate()).padStart(2, '0');
14
- return `${year}-${month}-${day}`;
11
+ const year = date.getFullYear();
12
+ const month = String(date.getMonth() + 1).padStart(2, '0');
13
+ const day = String(date.getDate()).padStart(2, '0');
14
+ return `${year}-${month}-${day}`;
15
15
  }
16
16
 
17
17
  /**
@@ -20,10 +20,10 @@ function formatDate(date) {
20
20
  * @return {string} - The formatted time string.
21
21
  */
22
22
  function formatTime(date) {
23
- const hours = String(date.getHours()).padStart(2, '0');
24
- const minutes = String(date.getMinutes()).padStart(2, '0');
25
- const seconds = String(date.getSeconds()).padStart(2, '0');
26
- return `${hours}:${minutes}:${seconds}`;
23
+ const hours = String(date.getHours()).padStart(2, '0');
24
+ const minutes = String(date.getMinutes()).padStart(2, '0');
25
+ const seconds = String(date.getSeconds()).padStart(2, '0');
26
+ return `${hours}:${minutes}:${seconds}`;
27
27
  }
28
28
 
29
29
  // Parsing Functions
@@ -34,8 +34,8 @@ function formatTime(date) {
34
34
  * @return {Date} - The parsed date object.
35
35
  */
36
36
  function parseDate(dateString) {
37
- const [year, month, day] = dateString.split('-').map(Number);
38
- return new Date(year, month - 1, day);
37
+ const [year, month, day] = dateString.split('-').map(Number);
38
+ return new Date(year, month - 1, day);
39
39
  }
40
40
 
41
41
  /**
@@ -44,10 +44,10 @@ function parseDate(dateString) {
44
44
  * @return {Date} - The parsed date object.
45
45
  */
46
46
  function parseTime(timeString) {
47
- const [hours, minutes, seconds] = timeString.split(':').map(Number);
48
- const date = new Date();
49
- date.setHours(hours, minutes, seconds, 0);
50
- return date;
47
+ const [hours, minutes, seconds] = timeString.split(':').map(Number);
48
+ const date = new Date();
49
+ date.setHours(hours, minutes, seconds, 0);
50
+ return date;
51
51
  }
52
52
 
53
53
  // Arithmetic Functions
@@ -59,9 +59,9 @@ function parseTime(timeString) {
59
59
  * @return {Date} - The new date object.
60
60
  */
61
61
  function addDays(date, days) {
62
- const result = new Date(date);
63
- result.setDate(result.getDate() + days);
64
- return result;
62
+ const result = new Date(date);
63
+ result.setDate(result.getDate() + days);
64
+ return result;
65
65
  }
66
66
 
67
67
  /**
@@ -71,7 +71,7 @@ function addDays(date, days) {
71
71
  * @return {Date} - The new date object.
72
72
  */
73
73
  function subtractDays(date, days) {
74
- return addDays(date, -days);
74
+ return addDays(date, -days);
75
75
  }
76
76
 
77
77
  /**
@@ -81,18 +81,17 @@ function subtractDays(date, days) {
81
81
  * @return {number} - The difference in days.
82
82
  */
83
83
  function differenceInDays(date1, date2) {
84
- const diffTime = date2 - date1;
85
- return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
84
+ const diffTime = date2 - date1;
85
+ return Math.ceil(diffTime / (1000 * 60 * 60 * 24));
86
86
  }
87
87
 
88
-
89
88
  // Exporting the functions as a CommonJS module
90
89
  module.exports = () => ({
91
- formatDate,
92
- formatTime,
93
- parseDate,
94
- parseTime,
95
- addDays,
96
- subtractDays,
97
- differenceInDays
90
+ formatDate,
91
+ formatTime,
92
+ parseDate,
93
+ parseTime,
94
+ addDays,
95
+ subtractDays,
96
+ differenceInDays,
98
97
  });
@@ -1,9 +1,7 @@
1
-
2
-
3
1
  module.exports = (context) => ({
4
- has: (key) => key in process.env,
5
- get: (key) => process.env[key],
6
- set: (key, value) => process.env[key] = value,
7
- rm: (key) => delete process.env[key],
8
- is: (key, value) => process.env[key] == value
9
- })
2
+ has: (key) => key in process.env,
3
+ get: (key) => process.env[key],
4
+ set: (key, value) => (process.env[key] = value),
5
+ rm: (key) => delete process.env[key],
6
+ is: (key, value) => process.env[key] == value,
7
+ });