https://github.com/overskul/objstr-resolver
A simple package to interact with object using string easily.
https://github.com/overskul/objstr-resolver
Last synced: 3 months ago
JSON representation
A simple package to interact with object using string easily.
- Host: GitHub
- URL: https://github.com/overskul/objstr-resolver
- Owner: overskul
- License: mit
- Created: 2024-07-06T16:30:58.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-06T19:00:19.000Z (11 months ago)
- Last Synced: 2025-02-14T14:40:29.963Z (4 months ago)
- Language: JavaScript
- Size: 78.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
A simple package to interact with object using string easily.
---
[![NPM downloads][download-image]][download-url]
[![NPM version][npm-image]][npm-url]
[npm-image]: https://img.shields.io/npm/v/objstr-resolver.svg?color=42cfff
[npm-url]: https://npmjs.org/package/objstr-resolver
[download-image]: https://img.shields.io/npm/dt/objstr-resolver.svg?color=3182b0
[download-url]: https://npmjs.org/package/objstr-resolver
---
## Installation
Install the package using `npm`:
```bash
npm install --save-dev objstr-resolver
```## Usage
```javascript
import {
resolve,
resolveObjValue,
resolveCondition,
resolveMath
} from 'objstr-resolver';console.log(resolve(`$1`, false)('hello world')); // hello world
console.log(resolve('$1>8')(9)); // trueconsole.log(
resolveObjValue('name.last')({ name: { first: '...', last:'name' } }) // name
);
console.log(resolveObjValue('name.1')({ name: ['...', 'name'] })); // name
console.log(resolve('$1>$1+1')(resolveObjValue('age')({ age: 23 }))); // trueconsole.log(resolveCondition('(1==2)&&(1!=3||1==0)')); // true
console.log(resolveCondition('true')); // trueconsole.log(resolveMath('1+2')); // 3
console.log(resolveMath('((1+2)*2)+((4/2)-1)')); // 7
```## Functions
```typescript
resolve(value: string, resolveConditions: boolean, resolveMaths: boolean): Function
```
- `value` the target value for resolve it.
- `resolveConditions` enable/disable resolve any condition in value. default `true`
- `resolveMaths` enable/disable resolve any math in value. default `true`
- that function compine ``, `` together.
```typescript
resolveObjValue(value: string): Function
```
- `value` the target value for resolve it.
```typescript
resolveCondition(value: string): Boolean
```
- `value` the target value for resolve it.
```typescript
resolveMath(value: string): Number
```
- `value` the target value for resolve it.## Friendly Note
This package is for personal use but i hope this package help someone if needed something like this.## Bugs & Feedbacks
any report for bugs or feedbacks you can create [issue here](https://github.com/NezitX/resolvex/issues).## Contributing
All [Contributing](https://github.com/NezitX/resolvex/pulls) are welcome `:)`## License
This package is under `MIT` license.