Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simonrichardson/typed-daggy
Typed version of daggy.
https://github.com/simonrichardson/typed-daggy
Last synced: 22 days ago
JSON representation
Typed version of daggy.
- Host: GitHub
- URL: https://github.com/simonrichardson/typed-daggy
- Owner: SimonRichardson
- Created: 2013-11-28T17:12:47.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2013-12-03T11:56:02.000Z (almost 11 years ago)
- Last Synced: 2024-05-01T23:21:53.750Z (6 months ago)
- Language: JavaScript
- Size: 102 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Typed daggy
Library for creating typed tagged constructors.
## Tagged
`daggy.tagged(types)(arguments)`
Creates a new constructor with the given field names as arguments
and properties. Allows instanceof checks with returned constructor.## Tagged Sum
```javascript
daggy.taggedSum({
Some: [{
name: 'x',
type: Number
}],
None: []
})
```Creates a constructor for each key in `constructors`. Returns a
function with each constructor as a property. Allows
`instanceof` checks for each constructor and the returned
function.```javascript
var Tuple3 = daggy.tagged({
name: 'x',
type: Number
}, {
name: 'y',
type: String
}, {
name: 'z',
type: Number
});var _123 = Tuple3(1, 'a', 3); // optional new keyword
_123.x == 1 && _123.y == 'a' && _123.z == 3; // true
_123 instanceof Tuple3; // true
```