@nhtio/encoder 0.1.0-master-cf69c10e → 0.1.0-master-492fadb0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nhtio/encoder",
3
- "version": "0.1.0-master-cf69c10e",
3
+ "version": "0.1.0-master-492fadb0",
4
4
  "description": "A portable cross-environment encoder / decoder for complex and structured data",
5
5
  "keywords": [],
6
6
  "author": "Jak Giveon <jak@nht.io>",
@@ -6482,6 +6482,8 @@ function friendlyDateTime$1(dateTimeish) {
6482
6482
  );
6483
6483
  }
6484
6484
  }
6485
+ const ENCODE_METHOD = Symbol.for("@nhtio/encoder:toEncoded");
6486
+ const DECODE_METHOD = Symbol.for("@nhtio/encoder:fromEncoded");
6485
6487
  var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __esmMin = (fn$1, res) => () => (fn$1 && (res = fn$1(fn$1 = 0)), res), __commonJSMin$1 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports), __export = (target, all$1) => {
6486
6488
  for (var name$2 in all$1) __defProp(target, name$2, { get: all$1[name$2], enumerable: true });
6487
6489
  }, __copyProps = (to, from$2, except, desc$1) => {
@@ -124106,33 +124108,43 @@ const isLuxonSystemZone = (value) => {
124106
124108
  const isBigInt = (value) => {
124107
124109
  return matchesSchema(value, bigintSchema);
124108
124110
  };
124111
+ const isCustomEncodable = (value) => {
124112
+ if (typeof value !== "object" || value === null) return false;
124113
+ if (!(ENCODE_METHOD in value) || typeof value[ENCODE_METHOD] !== "function") return false;
124114
+ const ctor = value.constructor;
124115
+ if (typeof ctor !== "function" || typeof ctor.name !== "string" || ctor.name === "") return false;
124116
+ return DECODE_METHOD in ctor && typeof ctor[DECODE_METHOD] === "function";
124117
+ };
124109
124118
  export {
124110
- DateTime$1 as D,
124119
+ DECODE_METHOD as D,
124120
+ ENCODE_METHOD as E,
124111
124121
  Info$1 as I,
124112
124122
  Phone as P,
124113
- isArray as a,
124114
- isSet as b,
124115
- isMap as c,
124116
- isLuxonSystemZone as d,
124117
- isLuxonInterval as e,
124118
- isLuxonDuration as f,
124119
- isLuxonDateTime as g,
124120
- isPhoneObject as h,
124123
+ isCustomEncodable as a,
124124
+ isArray as b,
124125
+ isSet as c,
124126
+ isMap as d,
124127
+ isLuxonSystemZone as e,
124128
+ isLuxonInterval as f,
124129
+ isLuxonDuration as g,
124130
+ isLuxonDateTime as h,
124121
124131
  isObject$1 as i,
124122
- isTypedArray as j,
124123
- isBigIntTypedArray as k,
124124
- isPrimitive as l,
124125
- isUniterableObject as m,
124126
- isError as n,
124127
- isBigInt as o,
124128
- isUnsafeInteger as p,
124129
- isNegativeInfinity as q,
124130
- isPositiveInfinity as r,
124131
- isNegativeZero as s,
124132
- Interval$1 as t,
124133
- Duration$1 as u,
124134
- isLucidBinaryValue as v,
124135
- isInstanceOf as w,
124136
- isNumber as x
124132
+ isPhoneObject as j,
124133
+ isTypedArray as k,
124134
+ isBigIntTypedArray as l,
124135
+ isPrimitive as m,
124136
+ isUniterableObject as n,
124137
+ isError as o,
124138
+ isBigInt as p,
124139
+ isUnsafeInteger as q,
124140
+ isNegativeInfinity as r,
124141
+ isPositiveInfinity as s,
124142
+ isNegativeZero as t,
124143
+ Interval$1 as u,
124144
+ DateTime$1 as v,
124145
+ Duration$1 as w,
124146
+ isLucidBinaryValue as x,
124147
+ isInstanceOf as y,
124148
+ isNumber as z
124137
124149
  };
124138
- //# sourceMappingURL=type_guards-UkDoe__i.mjs.map
124150
+ //# sourceMappingURL=type_guards-BAhiOypL.mjs.map