Registry / ai-ml / sury
library11.0.0-alpha.7jsnpmunverified

Sury is a composable schema validation and parsing library for JavaScript, TypeScript, and ReScript, currently at v11.0.0-alpha.7. It employs a JIT compilation approach using `new Function` to achieve the fastest validation performance in the ecosystem, as per benchmarks. The library offers over 100 operations, supports Standard Schema and JSON Schema, and has a modular, tree-shakable API similar to Valibot. It is released as an alpha with ongoing development.

npm install sury
INSTALL
IMPORT
SIG · SURY
S
sury
ai-mljavascriptv11.0.0-alpha.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

S
import { S } from 'sury'
import S from 'sury'
S is a named export, not a default export. It is a namespace object containing all schema constructors.
string
import { string } from 'sury'
const { string } = require('sury')
ESM-only package. CommonJS require is not supported.
parse
import { parse } from 'sury'
import { parse } from 'sury/parse'
parse is exported directly from the root package, not from a subpath.

Shows basic usage of Sury's object schema and parse function with TypeScript types.

import { S, parse, string, number, object } from 'sury'; const UserSchema = object({ name: string(), age: number() }); const user = parse(UserSchema, { name: 'Alice', age: 30 }); console.log(user); // { name: 'Alice', age: 30 }
Debug
Known issues
breakingUse of `new Function` for JIT compilation may be blocked in some environments (e.g., strict CSP, old Node versions).
fix
Ensure your runtime allows `new Function` or use a fallback schema library that does not rely on it.
affects: >=10.0.0
deprecatedAlpha version with API changes expected before stable release. Do not use in production.
fix
Wait for stable release or pin to older versions if needed.
affects: 11.x
gotchaSury uses `new Function` internally, which is prohibited in some serverless environments (e.g., Cloudflare Workers without the 'nodejs_compat' flag).
fix
Enable 'nodejs_compat' flag in Cloudflare Workers or avoid using Sury in restricted runtimes.
affects: >=10.0.0
gotchaNamed exports must be imported individually; importing the entire namespace via `import * as S from 'sury'` may lead to tree-shaking issues.
fix
Import only the specific functions you need (e.g., `import { S, parse, string } from 'sury'`).
affects: >=10.0.0
breakingVersion 11.0.0-alpha.x may contain breaking changes from v10; upgrade carefully.
fix
Review changelog before upgrading from v10 stable.
affects: 11.0.0-alpha.x
Errors
Common errors & fixes
SyntaxError: Unexpected token 'export'
Using CommonJS require() with an ESM-only package.
fix
Switch to ES modules (import) or use dynamic import if CommonJS is required.
TypeError: S.parse is not a function
Attempting to use S as a default import instead of named import.
fix
Use `import { S } from 'sury'` instead of `import S from 'sury'`.
Error: Cannot find module 'sury/parse'
Importing from a non-existent subpath.
fix
Import parse directly from 'sury' (e.g., `import { parse } from 'sury'`).
Upgrade
Version history
11.0.0-alpha.7latest on npm
Audit
Dependencies
rescriptoptionalPeer dependency for ReScript type definitions and compiler integration
Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
packagesury
sury — npm install sury · libregistry