npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

juof

v1.0.5

Published

For objects and functions manipulation in javascript. Use for inheritance, attribute etc.

Downloads

5

Readme

juof

For objects and functions manipulation in javascript. Use for inheritance, attribute etc.

Installation

$ npm install juof

Usage

var juof = require('juof');

function Person(name) {
    this.name = name;
}

function Male (name) {
    this.super(name); // Run base constructor function.
    this.gender = "M";
}

// Change the person class to person abtraction.
Person = juof.abstract(Person);

// The male class inherits from the person class.
Male = juof.inherit(Male, Person);

// Add prototype to the person class.
Person.prototype.cv = function () {
    console.log("Person.prototype.cv");
    console.log("Name: " + this.name);
}

// The male class shows the cv prototype of the person class.
new Male("JosephUz").cv();

// Override the cv prototype of the male class. 
Male.prototype.cv = function () {
    console.log("Male.prototype.cv");
    console.log("Name: " + this.name + '\nGender: ' + this.gender);
}

// The male class shows own cv prototype.
new Male("JosephUz").cv();

Methods

juof.abstract(type)

Parameters:

  • type: Type to be used.

juof.inherit(type, base)

Anymore, when creating a new instance of type, the last parameter of constructor will be base and in the same way the last parameter of base constructor will be type. Also, type constructor can only be called with "new" keyword or when base constructor has no returns. However, base constructor is always called.

Parameters:

  • type: Type to be used.

  • base: Inherited type.

juof.type

The object from which the related methods are handled.

juof.type.derived(type, base)

Checking that the type is derived from the base.

Parameters:

  • type: Type to be used.

  • base: Inherited type.

juof.type.clone(type)

Cloning with all the features of a type.

Parameters:

  • type: Type to be used.

juof.attribute

Used to manage operations before or after functions.

juof.attribute.inherit(attr)

Used to create a new attribute.

Parameters:

  • attr: Constructor function of the attribute to be derived.

juof.attribute.bind(func, attr, ...attr)

Used to bind the attribute with the function.

Parameters:

  • func: Function to which the attribute will be bound.

  • attr: Constructor function of the derived attribute. Multiple attributes can be written as parameters at the same bind process.

juof.attribute.getAppliedAttributes(scope, attr)

Used to get the applied attributes of a variable.

Parameters:

  • scope: The variable that attributes are applied to.

  • attr: Optional attribute parameter that is used to get the value of the attribute.

juof.attribute.getBoundAttributes(func, attr)

Used to get the applied attributes of a function.

Parameters:

  • func: The function that attributes are bound to.

  • attr: Optional attribute parameter that is used to get the value of the attribute.

juof.attribute.getAttributeResult(scope)

Used to get the result of the applied attributes to variable.

Parameters:

  • scope: The variable that attributes are applied to.

juof.function

Used to add tags to functions and to preserve the original form after manipulation.

juof.function.create(query, fn)

Create a new instance of JuFunction. Return instance of JuFunction.

Parameters:

  • query: String query of tags. Example: "number:0;boolean:true;string:text;array:one,two"

  • fn: Original function.

Or

juof.function.create(fn)

Parameters:

  • fn: Original function.

juof.function.define(scope, query, fn)

Create a new instance of JuFunction and define a field by function name into scope object. Return instance of JuFunction.

Parameters:

  • scope: Object that is defined a field by function name into.

  • query: String query of tags. Example: "number:0;boolean:true;string:text;array:one,two"

  • fn: Original function. Function that must be named. Example;


juof.function.define(scope, query, function test() { /* ... */ });

Or

juof.function.define(scope, fn)

Parameters:

  • scope: Object that is defined a field by function name into.

  • fn: Original function. Function that must be named.

juof.function.each(scope, eachFn)

Function that do forEach instances of JuFunction in the scope object.

Parameters:

  • scope: Object that is defined a field by function name into.

  • eachFn: Each function.

eachFn(instance)

juof.function.each(scope, function (instance) { ... })

Parameters:

  • instance: Instance of JuFunction.

instance of JuFunction

Fields:

  • tags: Object of tags.

  • scope: Object that is defined a field by function name into or bound object to function.

  • name: Original function name.

  • query: String query of tags.

  • function: Manipulated function.

  • original: Original function.

Prototypes:

  • bind: Runs as same in bind prototype of Function but available multiple times.

  • apply: Runs as same in apply prototype of Function.

  • call: Runs as same in call prototype of Function.

  • run: Runs the manipulated function.

  • pure: Runs the original function.

  • value: Manipulate function and manipulated function.

Changelog

All notable changes to this project will be documented in this file.

Changelog

Examples

Basic Usage

This example shows the most basic way of usage.

Attribute Usage

This example shows a way of the attribute usage.

License

This software is free to use under the JosephUz. See the LICENSE file for license text and copyright information.