Installation
Get started with Futurable in your project.
Package Managers
Install Futurable using your preferred package manager:
npm install @ndriadev/futurableyarn add @ndriadev/futurablepnpm add @ndriadev/futurablebun add @ndriadev/futurableRequirements
- Node.js: 14.0.0 or higher
- TypeScript: 4.5 or higher (optional, but recommended)
Module Systems
Futurable supports both ESM and CommonJS:
ESM (Recommended)
import { Futurable } from '@ndriadev/futurable';CommonJS
const { Futurable } = require('@ndriadev/futurable');CDN Usage
For quick prototyping or browser-only projects, you can use Futurable via CDN:
ESM CDN
<script type="module">
import { Futurable } from 'https://esm.sh/@ndriadev/futurable';
const request = Futurable.fetch('https://api.example.com/data');
</script>UMD (unpkg)
<script src="https://unpkg.com/@ndriadev/futurable"></script>
<script>
const { Futurable } = window.Futurable;
const request = Futurable.fetch('https://api.example.com/data');
</script>Browser Support
Futurable works in all modern browsers that support:
- ✅ ES2015 (ES6) features
- ✅ Promise API
- ✅ AbortController and AbortSignal
Supported Browsers
| Browser | Minimum Version |
|---|---|
| Chrome | 66+ |
| Firefox | 57+ |
| Safari | 12.1+ |
| Edge | 79+ |
Polyfills
If you need to support older browsers, you may need polyfills for:
Promise(for very old browsers)AbortController/AbortSignalfetchAPI
Example with polyfills:
<!-- Promise polyfill -->
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.min.js"></script>
<!-- AbortController polyfill -->
<script src="https://cdn.jsdelivr.net/npm/abortcontroller-polyfill@1/dist/abortcontroller-polyfill-only.min.js"></script>
<!-- Fetch polyfill -->
<script src="https://cdn.jsdelivr.net/npm/whatwg-fetch@3/dist/fetch.umd.js"></script>
<!-- Your code -->
<script src="your-app.js"></script>Node.js Support
Native Fetch API
Node.js includes native fetch support starting from version 17.5.0. For earlier versions, you'll need to install node-fetch:
npm install node-fetchThen import it globally:
import fetch from 'node-fetch';
global.fetch = fetch;
// Now Futurable.fetch will work
import { Futurable } from '@ndriadev/futurable';Recommended Node.js Versions
| Version | Support | Notes |
|---|---|---|
| 20.x | ✅ Recommended | LTS, native fetch |
| 18.x | ✅ Supported | LTS, native fetch |
| 16.x | ⚠️ Limited | EOL, requires node-fetch |
| 14.x | ⚠️ Limited | EOL, requires node-fetch |
TypeScript Configuration
If you're using TypeScript, ensure your tsconfig.json includes:
{
"compilerOptions": {
"target": "ES2015",
"module": "ESNext",
"lib": ["ES2015", "DOM"],
"moduleResolution": "node",
"esModuleInterop": true,
"skipLibCheck": true
}
}Verification
Verify your installation works:
import { Futurable } from '@ndriadev/futurable';
// Create a simple futurable
const test = new Futurable((resolve) => {
setTimeout(() => resolve('Installation successful! 🎉'), 1000);
});
test.then(message => console.log(message));If you see "Installation successful! 🎉" after 1 second, you're all set!
Next Steps
- Getting Started - Learn the basics
- API Reference - Explore the full API
- Examples - See real-world usage
Troubleshooting
Module not found
If you get "Cannot find module '@ndriadev/futurable'":
- Ensure the package is installed:
npm list @ndriadev/futurable - Clear your node_modules and reinstall:
rm -rf node_modules && npm install - Check your import statement syntax
TypeScript errors
If you get TypeScript errors:
- Ensure TypeScript version is 4.5+:
npm list typescript - Add
"skipLibCheck": trueto yourtsconfig.json - Check that
"moduleResolution": "node"is set
Fetch is not defined (Node.js)
If you get "fetch is not defined" in Node.js:
- Upgrade to Node.js 18+ for native fetch support
- Or install and import
node-fetchas shown above
AbortController is not defined
This is rare in modern environments, but if it happens:
- Install the polyfill:
npm install abortcontroller-polyfill - Import it before using Futurable:javascript
import 'abortcontroller-polyfill/dist/polyfill-patch-fetch';
Getting Help
If you encounter issues:
- 📖 Check the documentation
- 🐛 Report a bug
- 💬 Start a discussion
- 📧 Email: andreacosentino.work@gmail.com
