@aeriajs/common 0.0.23 → 0.0.25

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.
package/dist/schema.mjs CHANGED
@@ -1,72 +1,69 @@
1
- function _type_of(obj) {
2
- "@swc/helpers - typeof";
3
- return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
4
- }
5
- var mapValueToProperty = function(value) {
6
- if (value.constructor === Object) {
7
- return Object.assign({
8
- type: "object"
9
- }, fromLiteral(value));
10
- }
11
- if (value === Date) {
12
- return {
13
- type: "string",
14
- format: "date-time"
15
- };
16
- }
17
- if (Array.isArray(value)) {
18
- return {
19
- type: "array",
20
- items: mapValueToProperty(value[0])
21
- };
22
- }
23
- if (value && typeof value === "string") {
24
- return {
25
- $ref: value
26
- };
27
- }
1
+ "use strict";
2
+ const mapValueToProperty = (value) => {
3
+ if (value.constructor === Object) {
4
+ return Object.assign({
5
+ type: "object"
6
+ }, fromLiteral(value));
7
+ }
8
+ if (value === Date) {
28
9
  return {
29
- type: typeof value === "undefined" ? "undefined" : _type_of(value)
10
+ type: "string",
11
+ format: "date-time"
30
12
  };
31
- };
32
- export var fromLiteral = function(object, required) {
33
- var entries = [];
34
- for(var propName in object){
35
- var value = object[propName];
36
- if (value === null || value === undefined) {
37
- continue;
38
- }
39
- entries.push([
40
- propName,
41
- mapValueToProperty(value)
42
- ]);
43
- }
44
- var properties = Object.fromEntries(entries);
13
+ }
14
+ if (Array.isArray(value)) {
45
15
  return {
46
- type: "object",
47
- required: required,
48
- properties: properties
16
+ type: "array",
17
+ items: mapValueToProperty(value[0])
49
18
  };
50
- };
51
- export var leftSchema = function(object) {
19
+ }
20
+ if (value && typeof value === "string") {
52
21
  return {
53
- type: "object",
54
- properties: {
55
- _tag: {
56
- const: "Left"
57
- },
58
- value: object
59
- }
22
+ $ref: value
60
23
  };
24
+ }
25
+ return {
26
+ type: typeof value
27
+ };
61
28
  };
62
- export var rightSchema = function(object) {
63
- return {
64
- type: "object",
65
- properties: {
66
- _tag: {
67
- const: "Right"
68
- },
69
- value: object
70
- }
71
- };
29
+ export const fromLiteral = (object, required) => {
30
+ const entries = [];
31
+ for (const propName in object) {
32
+ const value = object[propName];
33
+ if (value === null || value === void 0) {
34
+ continue;
35
+ }
36
+ entries.push([
37
+ propName,
38
+ mapValueToProperty(value)
39
+ ]);
40
+ }
41
+ const properties = Object.fromEntries(entries);
42
+ return {
43
+ type: "object",
44
+ required,
45
+ properties
46
+ };
47
+ };
48
+ export const leftSchema = (object) => {
49
+ return {
50
+ type: "object",
51
+ properties: {
52
+ _tag: {
53
+ const: "Left"
54
+ },
55
+ value: object
56
+ }
57
+ };
58
+ };
59
+ export const rightSchema = (object) => {
60
+ return {
61
+ type: "object",
62
+ properties: {
63
+ _tag: {
64
+ const: "Right"
65
+ },
66
+ value: object
67
+ }
68
+ };
72
69
  };
@@ -1,38 +1,6 @@
1
- function _array_like_to_array(arr, len) {
2
- if (len == null || len > arr.length) len = arr.length;
3
- for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
- return arr2;
5
- }
6
- function _array_without_holes(arr) {
7
- if (Array.isArray(arr)) return _array_like_to_array(arr);
8
- }
9
- function _iterable_to_array(iter) {
10
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
11
- }
12
- function _non_iterable_spread() {
13
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
14
- }
15
- function _to_consumable_array(arr) {
16
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
17
- }
18
- function _unsupported_iterable_to_array(o, minLen) {
19
- if (!o) return;
20
- if (typeof o === "string") return _array_like_to_array(o, minLen);
21
- var n = Object.prototype.toString.call(o).slice(8, -1);
22
- if (n === "Object" && o.constructor) n = o.constructor.name;
23
- if (n === "Map" || n === "Set") return Array.from(n);
24
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
25
- }
26
- var _BSON;
1
+ "use strict";
27
2
  import * as BSON from "bson";
28
- export var serialize = function() {
29
- for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
30
- args[_key] = arguments[_key];
31
- }
32
- return Buffer.from((_BSON = BSON).serialize.apply(_BSON, _to_consumable_array(args))).toString("latin1");
33
- };
34
- export var deserialize = function(buffer) {
35
- return BSON.deserialize(new Uint8Array(Array.from(buffer).map(function(c) {
36
- return c.charCodeAt(0);
37
- })));
3
+ export const serialize = (...args) => Buffer.from(BSON.serialize(...args)).toString("latin1");
4
+ export const deserialize = (buffer) => {
5
+ return BSON.deserialize(new Uint8Array(Array.from(buffer).map((c) => c.charCodeAt(0))));
38
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/common",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -27,7 +27,7 @@
27
27
  }
28
28
  },
29
29
  "peerDependencies": {
30
- "@aeriajs/types": "^0.0.20",
30
+ "@aeriajs/types": "^0.0.22",
31
31
  "bson": "^5.4.0"
32
32
  },
33
33
  "scripts": {
@@ -36,7 +36,7 @@
36
36
  "lint:fix": "eslint src --fix",
37
37
  "build": "pnpm build:cjs && pnpm build:esm",
38
38
  "build:cjs": "tsc",
39
- "build:esm": "swc src/* -d dist --strip-leading-paths -C module.type=es6 --out-file-extension=mjs && pnpm build:esm-transform",
39
+ "build:esm": "esbuild './src/**/*.ts' --outdir=dist --out-extension:.js=.mjs && pnpm build:esm-transform",
40
40
  "build:esm-transform": "pnpm -w esm-transform $PWD/dist"
41
41
  }
42
42
  }