Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/y0hami/o

common object helper functions
https://github.com/y0hami/o

helper javascript object

Last synced: 3 months ago
JSON representation

common object helper functions

Awesome Lists containing this project

README

        

![o Logo](https://unpkg.com/[email protected]/logo.png)

# [o](https://github.com/hammy2899/o)
common object helper functions written in TypeScript which can be used in [NodeJS](https://nodejs.org/en/) and the browser (supports ES6).

[![GitHub Actions Status](https://github.com/hammy2899/o/workflows/CI/badge.svg)](https://github.com/hammy2899/o/actions)
[![Coverage Status](https://coveralls.io/repos/github/hammy2899/o/badge.svg?branch=master)](https://coveralls.io/github/hammy2899/o?branch=master)
[![npm version](https://img.shields.io/npm/v/o.svg)](https://www.npmjs.com/package/o)
[![license](https://img.shields.io/github/license/hammy2899/o.svg)](https://github.com/hammy2899/o/blob/master/LICENSE.md)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

### Installation

#### [NPM](https://npmjs.com)
```bash
$ npm install o
```

#### [Yarn](https://yarnpkg.com)
```bash
$ yarn add o
```

### Usage

#### TypeScript
```typescript
import o from 'o';
// or require specific functions
import { is, empty } from 'o';
```

#### NodeJS
```javascript
const o = require('o');
// or require specific functions
const { is, empty } = require('o');
```

#### Browser

##### ES6
```html

import './o.min.js';

```

##### CDN/Script
```html

```

### Example usage

```javascript
const a = {
a: 1,
b: 2,
c: {
d: 3,
e: 4,
},
};

is(a); // => true
empty(a); // => false
has(a, 'a'); // => true
has(a, 'd'); // => false
has(a, 'c.d'); // => true

const b = set(a, 'f', 5);
get(b, 'f'); // => 5
```

For more examples and a list of all functions view the [documentation page](https://o.hammy2899.dev).

### Documentation

You can view the [documentation here](https://o.hammy2899.dev), docs are generated by [TypeDoc](https://typedoc.org).

### Contributing

All functions are documented with [TypeDoc](https://typedoc.org) and are fully commented explaining how they works. If you want to
contribute feel free to open a PR. When you open a PR please make sure `yarn test` and `yarn lint` both pass
with no errors and if any tests fail or any linting issues are raised please fix them accordingly.