https://github.com/nesalia-inc/core
Zero-dependency monads for bulletproof TypeScript applications
https://github.com/nesalia-inc/core
error-handling functional-programming maybe monad outcome result typescript
Last synced: about 7 hours ago
JSON representation
Zero-dependency monads for bulletproof TypeScript applications
- Host: GitHub
- URL: https://github.com/nesalia-inc/core
- Owner: nesalia-inc
- License: mit
- Created: 2026-03-04T10:04:29.000Z (29 days ago)
- Default Branch: main
- Last Pushed: 2026-03-26T15:12:33.000Z (7 days ago)
- Last Synced: 2026-03-27T05:05:21.558Z (7 days ago)
- Topics: error-handling, functional-programming, maybe, monad, outcome, result, typescript
- Language: TypeScript
- Homepage: https://core.deessejs.com
- Size: 37 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 30
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
@deessejs/core
> Functional programming patterns for TypeScript.
## Packages
| Package | Description | Version |
|---------|-------------|---------|
| `@deessejs/core` | Functional programming patterns | [](https://www.npmjs.com/package/@deessejs/core) |
## Requirements
- TypeScript 5.0+
- Node.js 20+
## Installation
```bash
# Install core
npm install @deessejs/core
# Or using pnpm
pnpm add @deessejs/core
# Or using yarn
yarn add @deessejs/core
```
## Documentation
For full documentation, visit [core.deessejs.com](https://core.deessejs.com).
## Quick Start
```typescript
import { ok, err, isOk, isErr, Result } from '@deessejs/core'
// Ok - Normal Operation Result
const ok = ok({ id: 1, name: 'John' })
if (isOk(ok)) {
console.log(ok.value.name)
}
// Err - Domain Errors
const notFound = err({
name: 'NOT_FOUND',
message: 'User not found',
data: { id: 123 }
})
```
## Maybe Type
The `Maybe` type represents optional values - a value that may or may not be present. It's a safer alternative to `null`/`undefined`.
### Types
| Type | Description |
|------|-------------|
| `Maybe` | Union of `Some` or `None` |
| `Some` | A present value (`{ ok: true, value: T }`) |
| `None` | An absent value (`{ ok: false }`) |
### Functions
```typescript
import {
some, none,
fromNullable, isSome, isNone,
map, flatMap, getOrElse, getOrCompute,
tap, match, toNullable, toUndefined
} from '@deessejs/core'
// Creation
const present = some(42) // Some
const absent = none() // None
// From nullable
const value1 = fromNullable(42) // Some
const value2 = fromNullable(null) // None
const value3 = fromNullable(0) // Some (0 is a valid value)
// Type guards
isSome(present) // true
isNone(absent) // true
// Transform
map(present, x => x * 2) // Some<84>
flatMap(present, x => some(x * 2)) // Some<84>
flatMap(absent, x => some(x * 2)) // None
// Extract
getOrElse(present, 0) // 42
getOrElse(absent, 0) // 0
// Side effects
tap(present, console.log) // logs 42, returns Some<42>
match(present, v => v * 2, () => 0) // 84
match(absent, v => v * 2, () => 0) // 0
// Convert back
toNullable(present) // 42
toNullable(absent) // null
toUndefined(present) // 42
toUndefined(absent) // undefined
```
## Development
```bash
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Lint
pnpm lint
# Type check
pnpm typecheck
```
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Author
- **Nesalia Inc.**
## Security
If you discover any security vulnerabilities, please send an e-mail to security@nesalia.com.
## License
MIT License - see the [LICENSE](LICENSE) file for details.