https://github.com/joaocarmo/predictable
Predictable objects with consistent keys and default values
https://github.com/joaocarmo/predictable
Last synced: 5 months ago
JSON representation
Predictable objects with consistent keys and default values
- Host: GitHub
- URL: https://github.com/joaocarmo/predictable
- Owner: joaocarmo
- License: mit
- Created: 2019-09-23T12:57:14.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:01:58.000Z (about 3 years ago)
- Last Synced: 2025-07-19T21:05:08.742Z (6 months ago)
- Language: JavaScript
- Size: 404 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Predictable.js
[][1]
[][2]
Predictable objects with consistent keys and default values
## Usage
**Code**
```javascript
const predictableObj = new Predictable({
firstName: 'Homer',
lastName: 'Simpson',
})
predictableObj.set('age', 42)
const firstName = predictableObj.get('firstName')
const lastName = predictableObj.get(['lastName'])
const middleName = predictableObj.get('middleName', 'J.')
console.log(`Hello ! My name is ${firstName} ${middleName} ${lastName} and I'm ${predictableObj.age} years old.`)
```
**Output**
```
Hello ! My name is Homer J. Simpson and I'm 42 years old.
```
[1]: https://badge.fury.io/js/predictable
[2]: https://github.com/facebook/jest