Installation
How to install and set up @deessejs/fp in your project
Get up and running with @deessejs/fp in just a few minutes.
Install the Package
Install @deessejs/fp using your preferred package manager:
# pnpm (recommended)
pnpm add @deessejs/fp
# npm
npm install @deessejs/fp
# yarn
yarn add @deessejs/fpRequirements
- TypeScript 5.0 or higher
- Node.js 18 or higher
Quick Start
After installation, import the functions you need:
import { ok, err, map, Result } from "@deessejs/fp";
// Create a Result - explicit about potential failure
const divide = (a: number, b: number): Result<number, string> => {
if (b === 0) return err("Cannot divide by zero");
return ok(a / b);
};
// Use it - TypeScript forces you to handle errors
const result = divide(10, 2)
.map(x => x * 2)
.getOrElse(0);
console.log(result); // 5Tooltip Provider
The tooltip component has been added. Remember to wrap your app with the TooltipProvider component.
import { TooltipProvider } from "@/components/ui/tooltip"
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<TooltipProvider>{children}</TooltipProvider>
</body>
</html>
)
}TypeScript Configuration
No special TypeScript configuration is required. The library exports full type definitions out of the box.
For the best experience, ensure your tsconfig.json has strict mode enabled:
{
"compilerOptions": {
"strict": true
}
}Strict mode enables:
- Strict null checks
- No implicit any
- Strict property initialization
ESM Support
The package is published as an ES module. Ensure your package.json has:
{
"type": "module"
}If you're using CommonJS, import like this:
import { ok } from "@deessejs/fp/index.js";Importing from @deessejs/fp
Individual Imports (Recommended)
Import only what you need for smaller bundles:
import { ok, err, map, getOrElse } from "@deessejs/fp";All Exports
Import everything if needed:
import * as Deesse from "@deessejs/fp";
Deesse.ok(42);
Deesse.err("error");Next Steps
Now that you're set up: