@makano/rew 1.1.7 → 1.1.9

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.
Files changed (74) hide show
  1. package/README.md +1 -1
  2. package/bin/ui +0 -0
  3. package/build.sh +3 -1
  4. package/lib/coffeescript/browser.js +144 -139
  5. package/lib/coffeescript/cake.js +132 -133
  6. package/lib/coffeescript/coffeescript.js +437 -381
  7. package/lib/coffeescript/command.js +806 -724
  8. package/lib/coffeescript/grammar.js +1908 -2474
  9. package/lib/coffeescript/helpers.js +509 -473
  10. package/lib/coffeescript/index.js +228 -215
  11. package/lib/coffeescript/lexer.js +2282 -1909
  12. package/lib/coffeescript/nodes.js +9782 -9202
  13. package/lib/coffeescript/optparse.js +255 -227
  14. package/lib/coffeescript/parser.js +20305 -1265
  15. package/lib/coffeescript/register.js +107 -87
  16. package/lib/coffeescript/repl.js +307 -284
  17. package/lib/coffeescript/rewriter.js +1389 -1079
  18. package/lib/coffeescript/scope.js +176 -172
  19. package/lib/coffeescript/sourcemap.js +242 -227
  20. package/lib/rew/cli/cli.js +245 -186
  21. package/lib/rew/cli/log.js +31 -32
  22. package/lib/rew/cli/run.js +10 -12
  23. package/lib/rew/cli/utils.js +248 -175
  24. package/lib/rew/const/config_path.js +4 -0
  25. package/lib/rew/const/default.js +38 -35
  26. package/lib/rew/const/files.js +9 -9
  27. package/lib/rew/const/opt.js +8 -8
  28. package/lib/rew/css/theme.css +2 -2
  29. package/lib/rew/functions/core.js +55 -57
  30. package/lib/rew/functions/curl.js +23 -0
  31. package/lib/rew/functions/emitter.js +52 -55
  32. package/lib/rew/functions/exec.js +25 -21
  33. package/lib/rew/functions/export.js +18 -20
  34. package/lib/rew/functions/fs.js +55 -54
  35. package/lib/rew/functions/future.js +29 -21
  36. package/lib/rew/functions/id.js +8 -9
  37. package/lib/rew/functions/import.js +104 -93
  38. package/lib/rew/functions/map.js +13 -16
  39. package/lib/rew/functions/match.js +35 -26
  40. package/lib/rew/functions/path.js +8 -8
  41. package/lib/rew/functions/require.js +32 -33
  42. package/lib/rew/functions/sleep.js +2 -2
  43. package/lib/rew/functions/stdout.js +20 -20
  44. package/lib/rew/functions/types.js +96 -95
  45. package/lib/rew/html/ui.html +12 -13
  46. package/lib/rew/html/ui.js +205 -168
  47. package/lib/rew/main.js +14 -14
  48. package/lib/rew/misc/findAppInfo.js +16 -0
  49. package/lib/rew/misc/findAppPath.js +21 -0
  50. package/lib/rew/misc/seededid.js +13 -0
  51. package/lib/rew/models/enum.js +12 -12
  52. package/lib/rew/models/struct.js +30 -32
  53. package/lib/rew/modules/compiler.js +228 -177
  54. package/lib/rew/modules/context.js +35 -22
  55. package/lib/rew/modules/fs.js +10 -10
  56. package/lib/rew/modules/runtime.js +17 -21
  57. package/lib/rew/modules/yaml.js +27 -30
  58. package/lib/rew/pkgs/conf.js +82 -75
  59. package/lib/rew/pkgs/data.js +12 -7
  60. package/lib/rew/pkgs/date.js +27 -28
  61. package/lib/rew/pkgs/env.js +6 -8
  62. package/lib/rew/pkgs/modules/data/bintree.js +52 -52
  63. package/lib/rew/pkgs/modules/data/doublylinked.js +85 -85
  64. package/lib/rew/pkgs/modules/data/linkedList.js +73 -73
  65. package/lib/rew/pkgs/modules/data/queue.js +19 -20
  66. package/lib/rew/pkgs/modules/data/stack.js +19 -19
  67. package/lib/rew/pkgs/modules/threads/worker.js +36 -26
  68. package/lib/rew/pkgs/modules/ui/classes.js +182 -178
  69. package/lib/rew/pkgs/pkgs.js +9 -10
  70. package/lib/rew/pkgs/rune.js +422 -0
  71. package/lib/rew/pkgs/threads.js +57 -53
  72. package/lib/rew/pkgs/ui.js +148 -136
  73. package/meson.build +13 -0
  74. package/package.json +9 -2
@@ -1,39 +1,40 @@
1
1
  const defaultContext = require("../const/default");
2
2
  const { execOptions } = require("../const/opt");
3
- const emitter = require("../functions/emitter");
4
3
  const { exportsFunction, pubFunction } = require("../functions/export");
5
4
  const { imp } = require("../functions/import");
6
5
  const { customRequire } = require("../functions/require");
7
- const fsLib = require('../functions/fs');
8
- const pathLib = require('../functions/path');
9
- const execLib = require('../functions/exec');
6
+ const fsLib = require("../functions/fs");
7
+ const pathLib = require("../functions/path");
8
+ const execLib = require("../functions/exec");
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
+ app: findAppInfo(filepath),
31
32
  ...fsLib(filepath),
32
33
  };
33
34
  if (options.useContext) {
34
35
  context = {
35
36
  ...custom_context,
36
- ...context
37
+ ...context,
37
38
  };
38
39
  } else {
39
40
  context = {
@@ -43,9 +44,15 @@ module.exports.prepareContext = function (
43
44
  ...execLib(filepath),
44
45
  require: (package) => {
45
46
  try {
46
- 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);
47
54
  } catch (e) {
48
- throw new Error("Module "+package+" not found");
55
+ throw new Error("Module " + package + " not found");
49
56
  }
50
57
  },
51
58
  ...custom_context,
@@ -57,34 +64,40 @@ module.exports.prepareContext = function (
57
64
  target: {
58
65
  on: (event, listener) => process.on(event, listener),
59
66
  off: (event, listener) => process.off(event, listener),
60
- emit: (event, code) => process.emit(event, code)
67
+ emit: (event, code) => process.emit(event, code),
61
68
  },
62
69
  env: process.env,
63
70
  cwd: () => process.cwd(),
64
- arch: process.arch
71
+ arch: process.arch,
65
72
  };
66
-
73
+
67
74
  context.global = context;
68
75
  context.imports.assert = options.import ?? {};
69
76
  context.imp = imp(runPath, context);
70
77
  context.inc = (package, asserts) => {
71
- try{
72
- if(package.startsWith('node:') || package.startsWith('pkg:')) throw new Error('');
78
+ try {
79
+ if (package.startsWith("node:") || package.startsWith("pkg:"))
80
+ throw new Error("");
73
81
  return context.imp(package, asserts);
74
- } catch(e) {
75
- 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
+ );
76
86
  }
77
87
  };
78
88
  context.pub = pubFunction(context);
79
89
  context.exports = exportsFunction(context);
80
90
 
81
- if(context.module.main || (options.fromMain == true && options.as == 'main')){
91
+ if (
92
+ context.module.main ||
93
+ (options.fromMain == true && options.as == "main")
94
+ ) {
82
95
  context.opt = {
83
- set: (key, value) => execOptions[key] = value,
96
+ set: (key, value) => (execOptions[key] = value),
84
97
  get: (key) => execOptions[key],
85
98
  push: (key, value) => execOptions[key]?.push(value),
86
- pop: (key) => execOptions[key]?.pop()
99
+ pop: (key) => execOptions[key]?.pop(),
87
100
  };
88
- } else delete context.opt
101
+ } else delete context.opt;
89
102
  return context;
90
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
  });
@@ -1,92 +1,99 @@
1
1
  const fs = require('fs');
2
2
  const jsYaml = require('js-yaml');
3
3
  const path = require('path');
4
-
5
- const CONFIG_PATH = path.resolve(process.env.HOME, '.config/rew');
4
+ const { CONFIG_PATH } = require('../const/config_path');
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
- create: (packageName) => {
16
- 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
+
25
+ const conf = {};
17
26
 
18
- const conf = {};
27
+ const dumpYaml = (val) => {
28
+ if (JSON.stringify(val) == '{}') return '';
29
+ else return jsYaml.dump(val);
30
+ };
19
31
 
20
- const dumpYaml = (val) => {
21
- if(JSON.stringify(val) == '{}') return '';
22
- else return jsYaml.dump(val);
23
- }
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
+ };
24
37
 
25
- const setData = (optionCenter, key, value) => {
26
- conf[optionCenter.name][key] = value;
27
- fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
28
- return true;
29
- }
38
+ const removeData = (optionCenter, key) => {
39
+ delete conf[optionCenter.name][key];
40
+ fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
41
+ return true;
42
+ };
30
43
 
31
- const removeData = (optionCenter, key) => {
32
- delete conf[optionCenter.name][key];
33
- fs.writeFileSync(optionCenter.root, dumpYaml(conf[optionCenter.name]));
34
- return true;
35
- }
44
+ const getData = (optionCenter, key) => {
45
+ return conf[optionCenter.name][key];
46
+ };
36
47
 
37
- const getData = (optionCenter, key) => {
38
- return conf[optionCenter.name][key];
39
- }
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
+ };
40
60
 
41
- const staticFile = (name, defaultValue = "") => {
42
- const fileRoot = path.join(rootPath, name);
43
- const exists = fs.existsSync(fileRoot);
44
- return {
45
- create(value){
46
- if(!fs.existsSync(path.dirname(fileRoot))) fs.mkdirSync(path.dirname(fileRoot), { recursive: true });
47
- fs.writeFileSync(fileRoot, value || defaultValue);
48
- },
49
- fileRoot,
50
- exists
51
- }
52
- }
53
-
54
- const createOptionCenter = (name, defaults = {}) => {
55
- const optionRoot = path.join(rootPath, name+'.yaml');
56
- if(!fs.existsSync(path.dirname(optionRoot))) fs.mkdirSync(path.dirname(optionRoot), { recursive: true });
57
- if(!fs.existsSync(optionRoot)) {
58
- conf[name] = defaults;
59
- fs.writeFileSync(optionRoot, dumpYaml(defaults));
60
- } else {
61
- conf[name] = jsYaml.load(fs.readFileSync(optionRoot, { encoding: 'utf-8' }));
62
- }
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
+ }
63
70
 
64
- const optionCenter = {
65
- root: optionRoot,
66
- name,
67
- package: packageName
68
- }
71
+ const optionCenter = {
72
+ root: optionRoot,
73
+ name,
74
+ package: packageName,
75
+ };
69
76
 
70
- return {
71
- get: (key) => getData(optionCenter, key),
72
- set: (key, value) => setData(optionCenter, key, value),
73
- remove: (key) => removeData(optionCenter, key),
74
- reset: () => fs.writeFileSync(optionCenter.root, dumpYaml(defaults)) && (conf[name] = defaults),
75
- getAll: (str = false) => str ? dumpYaml(conf[name]) : conf[name],
76
- ...optionCenter
77
- }
78
- }
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
+ };
79
86
 
80
- const defaultCenter = createOptionCenter('_default', { default: true });
87
+ const defaultCenter = createOptionCenter('_default', { default: true });
81
88
 
82
- return {
83
- optionCenter: createOptionCenter,
84
- staticFile: staticFile,
85
- set: (key, value) => defaultCenter.set(key, value),
86
- get: (key) => defaultCenter.get(key),
87
- remove: (key) => defaultCenter.remove(key),
88
- root: rootPath,
89
- package: packageName
90
- }
91
- }
92
- });
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
+ });