Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nmtjs/type

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nmtjs/type - npm Package Compare versions

Comparing version 0.3.5 to 0.3.6

4

dist/index.js

@@ -5,3 +5,3 @@ import { ArrayType } from "./types/array.js";

import { DateType } from "./types/datetime.js";
import { EnumType, NativeEnumType } from "./types/enum.js";
import { EnumType, ObjectEnumType } from "./types/enum.js";
import { LiteralType } from "./types/literal.js";

@@ -30,3 +30,3 @@ import { BigIntType, IntegerType, NumberType } from "./types/number.js";

t.literal = (value)=>new LiteralType(value);
t.nativeEnum = (enumLike)=>new NativeEnumType(enumLike);
t.objectEnum = (enumLike)=>new ObjectEnumType(enumLike);
t.arrayEnum = (enumLike)=>new EnumType(enumLike);

@@ -33,0 +33,0 @@ t.date = ()=>new DateType();

import { NativeEnum } from "../schemas/native-enum.js";
import { UnionEnum } from "../schemas/union-enum.js";
import { BaseType } from "./base.js";
export class NativeEnumType extends BaseType {
export class ObjectEnumType extends BaseType {
values;

@@ -14,3 +14,3 @@ constructor(values, options = {}, isNullable = false, isOptional = false, hasDefault = false){

nullable() {
return new NativeEnumType(this.values, ...this._with({
return new ObjectEnumType(this.values, ...this._with({
isNullable: true

@@ -20,3 +20,3 @@ }));

optional() {
return new NativeEnumType(this.values, ...this._with({
return new ObjectEnumType(this.values, ...this._with({
isOptional: true

@@ -26,3 +26,3 @@ }));

nullish() {
return new NativeEnumType(this.values, ...this._with({
return new ObjectEnumType(this.values, ...this._with({
isNullable: true,

@@ -33,3 +33,3 @@ isOptional: true

default(value) {
return new NativeEnumType(this.values, ...this._with({
return new ObjectEnumType(this.values, ...this._with({
options: {

@@ -42,3 +42,3 @@ default: value

description(description) {
return new NativeEnumType(this.values, ...this._with({
return new ObjectEnumType(this.values, ...this._with({
options: {

@@ -50,3 +50,3 @@ description

examples(...examples) {
return new NativeEnumType(this.values, ...this._with({
return new ObjectEnumType(this.values, ...this._with({
options: {

@@ -53,0 +53,0 @@ examples

@@ -24,3 +24,3 @@ {

"temporal-polyfill": "^0.2.5",
"@nmtjs/common": "0.3.5"
"@nmtjs/common": "0.3.6"
},

@@ -30,3 +30,3 @@ "devDependencies": {

"temporal-polyfill": "^0.2.5",
"@nmtjs/common": "0.3.5"
"@nmtjs/common": "0.3.6"
},

@@ -40,3 +40,3 @@ "files": [

],
"version": "0.3.5",
"version": "0.3.6",
"scripts": {

@@ -43,0 +43,0 @@ "build": "neemata-build -p neutral --root=./src './**/*.ts'",

@@ -9,5 +9,5 @@ import type { TLiteralValue } from '@sinclair/typebox'

type AnyEnumType,
type AnyNativeEnumType,
type AnyObjectEnumType,
EnumType,
NativeEnumType,
ObjectEnumType,
} from './types/enum.ts'

@@ -70,4 +70,4 @@ import { type AnyLiteralType, LiteralType } from './types/literal.ts'

new LiteralType(value)
export const nativeEnum = <T extends { [K in string]: K }>(enumLike: T) =>
new NativeEnumType(enumLike)
export const objectEnum = <T extends { [K in string]: K }>(enumLike: T) =>
new ObjectEnumType(enumLike)
export const arrayEnum = <T extends (string | number)[]>(enumLike: [...T]) =>

@@ -84,3 +84,3 @@ new EnumType(enumLike)

| AnyEnumType
| AnyNativeEnumType
| AnyObjectEnumType
| AnyStringType

@@ -87,0 +87,0 @@ | AnyUnionType,

@@ -11,3 +11,3 @@ import {

[Kind]: typeof NativeEnumKind
static: T[keyof T][]
static: T[keyof T]
enum: T[keyof T][]

@@ -14,0 +14,0 @@ }

@@ -7,5 +7,5 @@ import type { SchemaOptions } from '@sinclair/typebox'

export type AnyNativeEnumType<T extends { [K in string]: K } = any> =
NativeEnumType<T, boolean, boolean, boolean>
export class NativeEnumType<
export type AnyObjectEnumType<T extends { [K in string]: K } = any> =
ObjectEnumType<T, boolean, boolean, boolean>
export class ObjectEnumType<
T extends { [K in string]: K },

@@ -31,11 +31,11 @@ N extends boolean = false,

nullable() {
return new NativeEnumType(this.values, ...this._with({ isNullable: true }))
return new ObjectEnumType(this.values, ...this._with({ isNullable: true }))
}
optional() {
return new NativeEnumType(this.values, ...this._with({ isOptional: true }))
return new ObjectEnumType(this.values, ...this._with({ isOptional: true }))
}
nullish() {
return new NativeEnumType(
return new ObjectEnumType(
this.values,

@@ -47,3 +47,3 @@ ...this._with({ isNullable: true, isOptional: true }),

default(value: keyof T) {
return new NativeEnumType(
return new ObjectEnumType(
this.values,

@@ -55,3 +55,3 @@ ...this._with({ options: { default: value }, hasDefault: true }),

description(description: string) {
return new NativeEnumType(
return new ObjectEnumType(
this.values,

@@ -63,3 +63,3 @@ ...this._with({ options: { description } }),

examples(...examples: (keyof T)[]) {
return new NativeEnumType(
return new ObjectEnumType(
this.values,

@@ -66,0 +66,0 @@ ...this._with({ options: { examples } }),

@@ -10,3 +10,3 @@ import {

import { BaseType, getTypeSchema } from './base.ts'
import { type AnyEnumType, type AnyNativeEnumType, EnumType } from './enum.ts'
import { type AnyEnumType, type AnyObjectEnumType, EnumType } from './enum.ts'
import type { AnyLiteralType } from './literal.ts'

@@ -148,3 +148,3 @@ import type { AnyStringType } from './string.ts'

| AnyEnumType
| AnyNativeEnumType
| AnyObjectEnumType
| AnyStringType

@@ -151,0 +151,0 @@ | AnyUnionType,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc