0.0.1 • Published 7 months ago

@orche/distinct v0.0.1

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
7 months ago

@orche/distinct

npm version npm download monthly npm download total github commit last github commit total npm license

//: <> (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

BSD-3-Clause

0.0.1

7 months ago