Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xxlabaza/object-accessor
Object accessor helper
https://github.com/xxlabaza/object-accessor
accessor helper object
Last synced: 14 days ago
JSON representation
Object accessor helper
- Host: GitHub
- URL: https://github.com/xxlabaza/object-accessor
- Owner: xxlabaza
- License: apache-2.0
- Created: 2020-06-06T22:55:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T08:10:39.000Z (almost 2 years ago)
- Last Synced: 2024-10-08T12:23:23.748Z (about 1 month ago)
- Topics: accessor, helper, object
- Language: TypeScript
- Size: 1.18 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Overview
[![Build Status](https://travis-ci.com/xxlabaza/object-accessor.svg?branch=master)](https://travis-ci.com/xxlabaza/object-accessor)
`ObjectAccessor` - is a helper wrapper for objects, which contains methods for retrieving the object's values by keys.
## Usage
> installation:
>
> ```bash
> $> npm install --save @xxlabaza/object-accessor
> ```Example:
```typescript
import { ObjectAccessor } from '@xxlabaza/object-accessor'const json = { ... };
const accessor = new ObjectAccessor(json);
accessor.getString('key1'); // => Result
accessor.getNumber('key2').or(42); // retrieve a number, or return 42, if undefined
accessor.getBoolean('key3.innerObjectKey').orError(); // try to get boolean from nested object or throw the Error
accessor.getObjectAccessor('key3').getBoolean('innerObjectKey').orError(); // the same as previous
```## Development
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
### Building
To build the project, do the following:
```bash
$> npm run build
...
```### Running the tests
To run the project's test, do the following:
```bash
$> npm test...
Test Suites: 1 passed, 1 total
Tests: 6 passed, 6 total
Snapshots: 0 total
Time: 1.233 s
Ran all test suites.
```## Changelog
To see what has changed in recent versions of the project, see the [changelog](./CHANGELOG.md) file.
## Contributing
Please read [contributing](./CONTRIBUTING.md) file for details on my code of conduct, and the process for submitting pull requests to me.
## Versioning
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/appulse-projects/utils-java/tags).
## Authors
* **[Artem Labazin](https://github.com/xxlabaza)** - creator and the main developer
## License
This project is licensed under the Apache License 2.0 License - see the [license](./LICENSE) file for details