common object helper functions written in TypeScript which can be used in NodeJS and the browser (supports ES6).
$ npm install o
$ yarn add o
import o from 'o';
// or require specific functions
import { is, empty } from 'o';
const o = require('o');
// or require specific functions
const { is, empty } = require('o');
<!-- Script tag -->
<script
type="module"
src="./o.min.js"
/>
<!-- Import syntax -->
<script type="text/javascript">
import './o.min.js';
</script>
<script
type="application/javascript"
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/o.min.js"
/>
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.
You can view the documentation here, docs are generated by TypeDoc.
All functions are documented with TypeDoc 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.