Introducing Identity.js, the 10x identity function.
The identity function,
At 10x'ly, we are always looking for new opportunities to make 10x libraries and then it struck us: what about an identity function? This package spreads 10x'ness into the simple concept of an identity function. It's not just an identity function, it's a 10x identity function.
This project is a standard Node.js module.
npm install @identity-js/identityThe function accepts a single argument of any type and returns that argument unchanged.
const identity = require("@identity-js/identity"); | Input Type | Code | Output |
|---|---|---|
| Number | identity(42) |
42 |
| String | identity('hello') |
'hello' |
| Object | const obj = {a: 1}; identity(obj) |
// returns the same object reference: {a: 1} |
| Null | identity(null) |
null |
Tests are written using Mocha.
Clone this repository, cd into packages/@identity-js/identity and install dependencies and dev-dependencies.
Execute the test suite :
npm test
This will execute the tests to ensure the function works correctly across various data types (numbers, strings, objects, booleans, null, and undefined).
This project is licensed under the Unlicense.