Skip to content

nuller is a simple library for providing default values for null or undefined object property access, created for/at the OSS workshop 🦁

License

Notifications You must be signed in to change notification settings

mrFunkyWisdom/nuller

Repository files navigation

nuller

Nuller is a small and simple library for providing default values for null or undefined object property access


Build Status codecov npm version Maintainability MIT Licence Open Source Love

Usage

nuller function can take parameters partially, first by providing the fallback object, and later to provide a real object.

import nuller from 'nuller';

const withFallback = nuller({
  name: 'John',
  lastName: 'Galt',
  location: 'unknown'
});

const originalObject = {
  name: 'John',
  location: null
};

const object = withFallback(originalObject);

console.log(
  `User ${object.name} ${object.lastName} lives in ${object.location} location`
);
//  User John Galt lives in unknown location
import nuller from 'nuller';

const fallbackObject = {
  name: 'John',
  lastName: 'Galt',
  location: 'unknown'
};

const originalObject = {
  name: 'John',
  location: null
};

const object = nuller(fallbackObject, originalObject);

console.log(
  `User ${object.name} ${object.lastName} lives in ${object.location} location`
);
//  User John Galt lives in unknown location

Installation

This module is distributed via npm and should be installed as your project's "dependencies"

npm install --save nuller

License

MIT © Ensar Bavrk

About

nuller is a simple library for providing default values for null or undefined object property access, created for/at the OSS workshop 🦁

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published