This package has been deprecated

Author message:

remove

null-object

1.0.0 • Public • Published

null-object

a Null Object is an object with defined neutral ("null") behavior. The Null Object design pattern describes the uses of such objects and their behavior (or lack thereof)

wiki for null object pattern;

Example

import nullObject from 'nullObject';

function UserFactory() {
let User = {
  sendEmail() {
    someEmailClient.send('Wellcome');
  }
};

let UserNull = nullObject(User);

if(session.isLogged()) {
  return User;
}

return UserNull;
}

let CurrentUser = UserFactory();
CurrentUser.sendEmail();

You shouldn't care if user is logged, just send messages for the object.

API

/**

  • @param {Object} object to be applied
  • @param {Object} [options]
  • @param {Boolean} [options.ownProps] only if Object.hasOwnProperty
  • @default [options.ownProps] false
  • @example
  • nullObject({ sendEmail() {/* ... */}, {ownProps: false}); */

Readme

Keywords

Package Sidebar

Install

npm i null-object

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • mateuspv