Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

classer

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

classer

Yet another way to create class-like object/functions with private, public, and static members

  • 0.3.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
increased by16.67%
Maintainers
1
Weekly downloads
 
Created
Source

classer

Install

$ npm i classer

Use

my-class.js:

/**
* private static:
**/
const H_LOOKUP = {
	a: 'arnold',
	b: 'batman',	
};

/**
* class:
**/
const local = classer('MyClass', (h_config) => {
	
	/**
	* private fields:
	**/
	let {
		name: s_name,
		limit: n_limit,
	} = h_config;

	/**
	* private methods:
	**/
	const run_task = () => {
		n_limit += 1;
	};

	/**
	* public:
	**/
	return classer.operator(function() {
		return 'hi! I am '+s_name;
	}, {
		org: 2,

		getName() {
			return s_name;
		},

		change() {
			run_task();
		},
	};
},
	/**
	* public static:
	**/
	{
	
	help: () => {
		return 'help yourself';
	},
});

// exports
export default local;

index.js:

import MyClass from './my-class.js';

let instance = MyClass({name: 'cartman', limit: 5});
instance(); // 'hi! I am cartman'
instance.getName(); // 'cartman'
MyClass.help(); // 'help yourself'

Keywords

FAQs

Package last updated on 02 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc