New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

isly

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isly - npm Package Compare versions

Comparing version 0.1.12 to 0.1.13

6

dist/cjs/intersection.js

@@ -31,10 +31,10 @@ "use strict";

for (const key in source)
if (Object.getOwnPropertyDescriptor(target, key) &&
if (globalThis.Object.getOwnPropertyDescriptor(target, key) &&
typeof target[key] == "object" &&
typeof source[key] == "object")
Object.assign(target, {
globalThis.Object.assign(target, {
[key]: this.merge(target[key], source[key]),
});
else
Object.assign(target, { [key]: source[key] });
globalThis.Object.assign(target, { [key]: source[key] });
return result;

@@ -41,0 +41,0 @@ }

@@ -18,2 +18,6 @@ import { Type } from "./Type";

extend<T2 extends T>(properties: ExtendedProperties<T2, T>, name?: string): ExtendableType<T2>;
omit<K extends keyof T>(omits: readonly K[], name?: string): object.ExtendableType<Omit<T, K>>;
omit<T2 extends Omit<T, K>, K extends keyof T>(omits: readonly K[], name?: string): object.ExtendableType<T2>;
pick<K extends keyof T>(picks: readonly K[], name?: string): object.ExtendableType<Pick<T, K>>;
pick<T2 extends Pick<T, K>, K extends keyof T>(picks: readonly K[], name?: string): object.ExtendableType<T2>;
}

@@ -20,0 +24,0 @@ }

@@ -22,2 +22,10 @@ "use strict";

}
omit(omits, name) {
var _a;
return new IslyObject((_a = this.baseType) === null || _a === void 0 ? void 0 : _a.omit(omits), globalThis.Object.fromEntries(globalThis.Object.entries(this.properties).filter(([key]) => !omits.includes(key))), name !== null && name !== void 0 ? name : `Omit<${this.name}, ${omits.map(key => `"${String(key)}"`).join(" | ")}>`);
}
pick(picks, name) {
var _a;
return new IslyObject((_a = this.baseType) === null || _a === void 0 ? void 0 : _a.pick(picks), globalThis.Object.fromEntries(globalThis.Object.entries(this.properties).filter(([key]) => picks.includes(key))), name !== null && name !== void 0 ? name : `Pick<${this.name}, ${picks.map(key => `"${String(key)}"`).join(" | ")}>`);
}
createFlaw(value) {

@@ -24,0 +32,0 @@ var _a, _b;

@@ -29,3 +29,3 @@ "use strict";

getValue(value) {
return Object.fromEntries(Object.entries(value).map(([key, value]) => [key, this.valueType.get(value)]));
return globalThis.Object.fromEntries(globalThis.Object.entries(value).map(([key, value]) => [key, this.valueType.get(value)]));
}

@@ -32,0 +32,0 @@ }

@@ -11,3 +11,3 @@ "use strict";

? `/${conditionObject.source}/${conditionObject.flags}`
: Object.keys(conditionObject)
: globalThis.Object.keys(conditionObject)
.map(key => `"${key}"`)

@@ -33,3 +33,3 @@ .join(" | ");

return result;
}, Object.create(null))
}, globalThis.Object.create(null))
: typeof this.stringCondition == "string"

@@ -36,0 +36,0 @@ ? { [this.stringCondition]: true }

@@ -28,10 +28,10 @@ import { Type } from "./Type";

for (const key in source)
if (Object.getOwnPropertyDescriptor(target, key) &&
if (globalThis.Object.getOwnPropertyDescriptor(target, key) &&
typeof target[key] == "object" &&
typeof source[key] == "object")
Object.assign(target, {
globalThis.Object.assign(target, {
[key]: this.merge(target[key], source[key]),
});
else
Object.assign(target, { [key]: source[key] });
globalThis.Object.assign(target, { [key]: source[key] });
return result;

@@ -38,0 +38,0 @@ }

@@ -18,2 +18,6 @@ import { Type } from "./Type";

extend<T2 extends T>(properties: ExtendedProperties<T2, T>, name?: string): ExtendableType<T2>;
omit<K extends keyof T>(omits: readonly K[], name?: string): object.ExtendableType<Omit<T, K>>;
omit<T2 extends Omit<T, K>, K extends keyof T>(omits: readonly K[], name?: string): object.ExtendableType<T2>;
pick<K extends keyof T>(picks: readonly K[], name?: string): object.ExtendableType<Pick<T, K>>;
pick<T2 extends Pick<T, K>, K extends keyof T>(picks: readonly K[], name?: string): object.ExtendableType<T2>;
}

@@ -20,0 +24,0 @@ }

@@ -20,2 +20,8 @@ import { Type } from "./Type";

}
omit(omits, name) {
return new IslyObject(this.baseType?.omit(omits), globalThis.Object.fromEntries(globalThis.Object.entries(this.properties).filter(([key]) => !omits.includes(key))), name ?? `Omit<${this.name}, ${omits.map(key => `"${String(key)}"`).join(" | ")}>`);
}
pick(picks, name) {
return new IslyObject(this.baseType?.pick(picks), globalThis.Object.fromEntries(globalThis.Object.entries(this.properties).filter(([key]) => picks.includes(key))), name ?? `Pick<${this.name}, ${picks.map(key => `"${String(key)}"`).join(" | ")}>`);
}
createFlaw(value) {

@@ -22,0 +28,0 @@ return {

@@ -26,3 +26,3 @@ import { Type } from "./Type";

getValue(value) {
return Object.fromEntries(Object.entries(value).map(([key, value]) => [key, this.valueType.get(value)]));
return globalThis.Object.fromEntries(globalThis.Object.entries(value).map(([key, value]) => [key, this.valueType.get(value)]));
}

@@ -29,0 +29,0 @@ }

@@ -8,3 +8,3 @@ import { Type } from "./Type";

? `/${conditionObject.source}/${conditionObject.flags}`
: Object.keys(conditionObject)
: globalThis.Object.keys(conditionObject)
.map(key => `"${key}"`)

@@ -29,3 +29,3 @@ .join(" | ");

return result;
}, Object.create(null))
}, globalThis.Object.create(null))
: typeof this.stringCondition == "string"

@@ -32,0 +32,0 @@ ? { [this.stringCondition]: true }

@@ -34,11 +34,11 @@ import { Flaw } from "./Flaw"

if (
Object.getOwnPropertyDescriptor(target, key) &&
globalThis.Object.getOwnPropertyDescriptor(target, key) &&
typeof target[key as string as keyof typeof target] == "object" &&
typeof source[key] == "object"
)
Object.assign(target, {
globalThis.Object.assign(target, {
[key]: this.merge(target[key as string as keyof typeof target], source[key]),
})
else
Object.assign(target, { [key]: source[key] })
globalThis.Object.assign(target, { [key]: source[key] })

@@ -45,0 +45,0 @@ return result

@@ -20,2 +20,6 @@ import type { Flaw } from "./Flaw"

extend<T2 extends T>(properties: ExtendedProperties<T2, T>, name?: string): ExtendableType<T2>
omit<K extends keyof T>(omits: readonly K[], name?: string): object.ExtendableType<Omit<T, K>>
omit<T2 extends Omit<T, K>, K extends keyof T>(omits: readonly K[], name?: string): object.ExtendableType<T2>
pick<K extends keyof T>(picks: readonly K[], name?: string): object.ExtendableType<Pick<T, K>>
pick<T2 extends Pick<T, K>, K extends keyof T>(picks: readonly K[], name?: string): object.ExtendableType<T2>
}

@@ -52,2 +56,20 @@ }

}
omit<K extends keyof T>(omits: readonly K[], name?: string): object.ExtendableType<Omit<T, K>> {
return new IslyObject<Omit<T, K>, Omit<T, K>, any>(
this.baseType?.omit(omits as any),
globalThis.Object.fromEntries(
globalThis.Object.entries(this.properties).filter(([key]) => !omits.includes(key as any))
) as any,
name ?? `Omit<${this.name}, ${omits.map(key => `"${String(key)}"`).join(" | ")}>`
)
}
pick<K extends keyof T>(picks: readonly K[], name?: string): object.ExtendableType<Pick<T, K>> {
return new IslyObject<Pick<T, K>, Pick<T, K>, any>(
this.baseType?.pick(picks as any),
globalThis.Object.fromEntries(
globalThis.Object.entries(this.properties).filter(([key]) => picks.includes(key as any))
) as any,
name ?? `Pick<${this.name}, ${picks.map(key => `"${String(key)}"`).join(" | ")}>`
)
}
is = (value =>

@@ -54,0 +76,0 @@ !!(

{
"name": "isly",
"version": "0.1.12",
"version": "0.1.13",
"description": "Library for type checking.",

@@ -5,0 +5,0 @@ "author": "Utily Contributors",

@@ -76,23 +76,2 @@ # isly

## Extending types
`isly.object()` returns a type which is extendable.
```typescript
interface Item1 {
i1: number
}
interface Item2 extends Item1 {
i2: number
}
interface Item3 extends Item2 {
i3: number
}
const typeItem1 = isly.object<Item1>({ i1: isly.number() }, "Item1")
// It is possible (but optional) to add conditions to properties in the base-type:
const typeItem2 = typeItem1.extend<Item2>({ i2: isly.number(), i1: isly.number(value => value >= 400) }, "Item2")
const typeItem3 = typeItem2.extend<Item3>({ i3: isly.number() }, "Item3")
```
## type.get(value: any)

@@ -148,3 +127,3 @@

Add `| undefined`to type.
Add `| undefined` to type.

@@ -155,2 +134,55 @@ ### .readonly()

## Modifiers for isly.object
`isly.object()` returns a type which has more modifiers.
### .extend()
```typescript
interface Item1 {
i1: number
}
interface Item2 extends Item1 {
i2: number
}
interface Item3 extends Item2 {
i3: number
}
const typeItem1 = isly.object<Item1>({ i1: isly.number() }, "Item1")
// It is possible (but optional) to add conditions to properties in the base-type:
const typeItem2 = typeItem1.extend<Item2>({ i2: isly.number(), i1: isly.number(value => value >= 400) }, "Item2")
const typeItem3 = typeItem2.extend<Item3>({ i3: isly.number() }, "Item3")
```
### .pick()
```typescript
interface User {
firstName: string
lastName: string
password: string
}
type UserWithoutCredentials = Pick<User, "firstName" | "lastName">
const userType = isly.object<User>({ firstName: isly.string(), lastName: isly.string(), password: isly.string() })
const UserWithoutCredentials = userType.pick(["firstName", "lastName"], "UserWithoutCredentials")
```
### .omit()
```typescript
interface User {
firstName: string
lastName: string
password: string
}
type UserWithoutCredentials = Omit<User, "password">
const userType = isly.object<User>({ firstName: isly.string(), lastName: isly.string(), password: isly.string() })
const UserWithoutCredentials = userType.omit(["password"], "UserWithoutCredentials")
```
## Usage patterns

@@ -157,0 +189,0 @@

@@ -35,6 +35,5 @@ import { Flaw } from "./Flaw"

protected getValue(value: Record<K, V>): Record<K, V> {
return Object.fromEntries(Object.entries(value).map(([key, value]) => [key, this.valueType.get(value)])) as Record<
K,
V
>
return globalThis.Object.fromEntries(
globalThis.Object.entries(value).map(([key, value]) => [key, this.valueType.get(value)])
) as Record<K, V>
}

@@ -41,0 +40,0 @@ }

@@ -10,3 +10,3 @@ import { Type } from "./Type"

? `/${conditionObject.source}/${conditionObject.flags}`
: Object.keys(conditionObject)
: globalThis.Object.keys(conditionObject)
.map(key => `"${key}"`)

@@ -33,3 +33,3 @@ .join(" | ")

return result
}, Object.create(null))
}, globalThis.Object.create(null))
: typeof this.stringCondition == "string"

@@ -36,0 +36,0 @@ ? { [this.stringCondition]: true }

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

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