Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thecymaera/fluent-interfaces
https://github.com/thecymaera/fluent-interfaces
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/thecymaera/fluent-interfaces
- Owner: TheCymaera
- Created: 2022-02-12T08:58:54.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-12T09:12:09.000Z (almost 3 years ago)
- Last Synced: 2024-12-16T16:05:45.285Z (12 days ago)
- Language: TypeScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fluent
## Installation
Install via [npm](https://www.npmjs.com/package/fluent-interfaces):
```shell
npm install fluent-interfaces
```## Information
Many JavaScript libraries use fluent-interfaces, but they are not at all ***fluent*** when working with 3rd party functions.
```typescript
externalFunction3(
externalFunction2(
externalFunction1(
new Widget()
.setTitle("Hello World!")
.setDescription("Welcome to my website!")
)
)
)
```This library adds global methods for working with fluent interfaces.
```typescript
import { cascade, transform } from "fluent-interfaces";new Widget()
.setTitle("Hello World!")
.setDescription("Welcome to my website!")
[cascade](externalFunction1)
[cascade](externalFunction2)
[cascade](externalFunction3)
[cascade](self=>console.log("Created widget:", self))
// returns Widgetnew Widget()
.setTitle("Hello World!")
.setDescription("Welcome to my website!")
[transform](self=>new Wrapper(self))
// returns Wrapper
```## License
MIT License.
All files can be used for commercial or non-commercial purposes. Do not resell. Attribution is appreciated but not due.