https://github.com/flarebyte/object-crumble
Creative ways to cook your object
https://github.com/flarebyte/object-crumble
npm-package
Last synced: 14 days ago
JSON representation
Creative ways to cook your object
- Host: GitHub
- URL: https://github.com/flarebyte/object-crumble
- Owner: flarebyte
- License: mit
- Created: 2021-12-26T16:44:53.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-08T03:19:00.000Z (over 3 years ago)
- Last Synced: 2024-04-26T19:02:30.285Z (about 2 years ago)
- Topics: npm-package
- Language: TypeScript
- Homepage:
- Size: 263 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Object-crumble
 





> Creative ways to cook your objects
The main motivation is to boost the writing of unit tests by simplifying the
process of creating new data content. This is achieved by mutating
programmatically existing data:
- Written in `Typescript`.
- Uses JSON-like object as an input.
- Can be used with any testing framework (Jest, ...)
- A simpler and experimental alternative to property testing. **No need
for a schema**. You should still consider, property based testing
framework
like[fast-check](https://dubzzz.github.io/fast-check.github.com/) that
can help find bugs in unexplored code paths.
## Usage
Convert any object to an abstract representation of the object structure
abstractObject({name: "Jane", homepage: "" })
will return:
```typescript
[
{
path: "name",
kind: "string",
},
{
path: "homepage",
kind: "url",
},
];
```
Mutates an object applying a mutation.
```typescript
const mutation = {
path: "name",
kind: "string",
mutationName: "string => empty",
};
mutateObject(mutatorRules)(mutation)({
name: "Picasso",
firstName: "Pablo",
});
```
will return empty field for `name`:
```typescript
{
name: '',
firstName: 'Pablo'
}
```
A more exhaustive documentation of the api is [available](API.md)
## Documentation and links
- [Code Maintenance](MAINTENANCE.md)
- [Code Of Conduct](CODE_OF_CONDUCT.md)
- [Api for object-crumble](API.md)
- [Contributing](CONTRIBUTING.md)
- [Glossary](GLOSSARY.md)
- [Diagram for the code base](INTERNAL.md)
- [Vocabulary used in the code base](CODE_VOCABULARY.md)
- [Architectural Decision Records](DECISIONS.md)
- [Contributors](https://github.com/flarebyte/object-crumble/graphs/contributors)
- [Dependencies](https://github.com/flarebyte/object-crumble/network/dependencies)
## Installation
This package is [ESM
only](https://blog.sindresorhus.com/get-ready-for-esm-aa53530b3f77).
```bash
yarn add object-crumble
```