0.0.1 • Published 7 months ago
@orche/distinct v0.0.1
@orche/distinct
//: <> (Shields)
//: <> (Links)
Overview
A lightweight identity function that returns its input unchanged. Perfect for functional composition and default transformations.
Features
- Zero dependencies
- Tiny footprint (<1KB)
- Pure function
- ESM support
Installation
# npm
$ npm install @orche/distinct
# yarn
$ yarn add @orche/distinct
# pnpm
$ pnpm add @orche/distinct
Usage
import { oneself } from '@orche/distinct'
// Basic usage
oneself(42) // => 42
oneself('hello') // => 'hello'
oneself([1, 2, 3]) // => [1, 2, 3]
// Function composition
const pipeline = [oneself, String, parseInt]
const result = pipeline.reduce((x, f) => f(x), 42) // => 42
// Default transformer
const transform = condition ? complexTransform : oneself
License
0.0.1
7 months ago