@typed/guard 0.7.0 → 0.7.1

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.
@@ -1,5 +1,5 @@
1
1
  import { Pipeable } from 'effect';
2
- import { ExtensibleFunction } from './ExtensibleFunction';
2
+ import { ExtensibleFunction } from './ExtensibleFunction.js';
3
3
  import type { Guard } from './Guard.js';
4
4
  export declare const GUARDABLE: unique symbol;
5
5
  export type GUARDABLE = typeof GUARDABLE;
package/dist/Guardable.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Pipeable } from 'effect';
2
- import { ExtensibleFunction } from './ExtensibleFunction';
2
+ import { ExtensibleFunction } from './ExtensibleFunction.js';
3
3
  export const GUARDABLE = Symbol.for('@typed/guard/Guardable');
4
4
  export class Guardable extends ExtensibleFunction {
5
5
  constructor() {
@@ -1 +1 @@
1
- {"version":3,"file":"Guardable.js","sourceRoot":"","sources":["../src/Guardable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAGzD,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAG7D,MAAM,OAAgB,SAAsC,SAAQ,kBAEnE;IACC;QACE,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1C,CAAC;IAID,IAAI;QACF,mEAAmE;QACnE,OAAO,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAChD,CAAC;CACF"}
1
+ {"version":3,"file":"Guardable.js","sourceRoot":"","sources":["../src/Guardable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AAG7D,MAAM,OAAgB,SACpB,SAAQ,kBAAqC;IAG7C;QACE,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1C,CAAC;IAID,IAAI;QACF,mEAAmE;QACnE,OAAO,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAChD,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typed/guard",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Guards with Effect",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -73,7 +73,7 @@ const stringToLength = (s: string) =>
73
73
  Effect.succeed(s.length > 1 ? Option.some(s.length) : Option.none())
74
74
 
75
75
  // Compose them together
76
- const composed: Guard<number, number> = Guard.compose(isPositive, stringLength)
76
+ const composed: Guard<number, number> = Guard.compose(numberToString, stringLength)
77
77
  ```
78
78
 
79
79
  #### Filtering and Mapping
@@ -108,12 +108,14 @@ const withTaggedRecovery = Guard.catchTag(
108
108
  ```typescript
109
109
  import { Schema } from 'effect'
110
110
 
111
- const PersonSchema = Schema.struct({
111
+ const PersonSchema = Schema.Struct({
112
112
  name: Schema.string,
113
113
  age: Schema.number
114
114
  })
115
115
 
116
116
  const personGuard = Guard.fromSchemaDecode(PersonSchema)
117
+ const personGuard = Guard.fromSchemaDecodeUnknown(PersonSchema)
118
+ const personGuard = Guard.fromSchemaEncode(PersonSchema)
117
119
  ```
118
120
 
119
121
  ## Advanced Usage
@@ -98,7 +98,5 @@ describe('ExtensibleFunction', () => {
98
98
  expect(composed(3)).toBe(8) // (3 + 1) * 2
99
99
  })
100
100
 
101
- it('should allow class decorator', () => {
102
-
103
- })
101
+ it('should allow class decorator', () => {})
104
102
  })
package/src/Guard.test.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Effect, identity, Option, pipe, Predicate, Schema } from 'effect'
1
+ import { Effect, Option, pipe, Predicate, Schema } from 'effect'
2
2
  import { describe, expect, it } from 'vitest'
3
- import * as Guard from './Guard'
3
+ import * as Guard from './Guard.js'
4
4
 
5
5
  describe('Guard', () => {
6
6
  // Helper function to run a guard and get the result
package/src/Guardable.ts CHANGED
@@ -1,13 +1,14 @@
1
1
  import { Pipeable } from 'effect'
2
- import { ExtensibleFunction } from './ExtensibleFunction'
2
+ import { ExtensibleFunction } from './ExtensibleFunction.js'
3
3
  import type { Guard } from './Guard.js'
4
4
 
5
5
  export const GUARDABLE = Symbol.for('@typed/guard/Guardable')
6
6
  export type GUARDABLE = typeof GUARDABLE
7
7
 
8
- export abstract class Guardable<I, O, E = never, R = never> extends ExtensibleFunction<
9
- Guard<I, O, E, R>
10
- > implements Pipeable.Pipeable {
8
+ export abstract class Guardable<I, O, E = never, R = never>
9
+ extends ExtensibleFunction<Guard<I, O, E, R>>
10
+ implements Pipeable.Pipeable
11
+ {
11
12
  constructor() {
12
13
  super((input) => this[GUARDABLE](input))
13
14
  }