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

emotions

v0.0.1

Published

require('emotions/delight')

Downloads

87

Readme

$ npm install emotions

A small npm module that adds emotions to your code.

require('emotions/delight');
require('emotions').delight;
// or
import {delight} from 'emotions';
import delight from 'emotions/delight';

// Scale emotions for more nuance
require('emotions/love')(0.2); // 20% love

// Mix together multiple emotions
import {hope, envy} from 'emotions';

Available Emotions

emotions provides 100% coverage of all human emotions, as defined by the HUMAINE Emotion Annotation and Representation Language (EARL):

affection
amusement
anger
annoyance
anxiety
boredom
calm
contempt
content
courage
delight
despair
disappointment
disgust
doubt
elation
embarrassment
empathy
envy
excitement
fear
friendliness
frustration
guilt
happiness
helplessness
hope
hurt
interest
irritation
joy
love
pleasure 
politeness
powerlessness
pride
relaxed
relieved
sadness 
satisfaction
serene 
shame 
shock
stress
surprise
tension
trust
worry

API

The top level emotions module contains all emotions:

var anger = require('emotions').anger;

or, using import and destructuring:

import {anger} from 'emotions';

You can also import specific emotions:

var anger = require('emotions/anger');
import anger from 'emotions/anger';

Scaling Emotions

By default, emotions are applied at 100% strength. You can also pass a scaling factor to the emotion for more nuanced emotional states:

require('emotions/anger')(0.5); // 50% anger
require('emotions/excitement')(5.0); // 500% excitement

The top level module can also take a set of emotions to import and their weights:

var emotions = require('emotions')({
    anger: 0.5,
    excitment; 5.0
});

Mixing Emotions

Introduce multiple emotions into a single file just by adding multiple imports:

import {love} from 'emotions';
import {elation} from 'emotions';

// or

import {love, elation} from 'emotions';

Frequently Asked Questions

How does it work?

You can think of each emotion as a function with the following signature:

function(world) {
    // something happens
    return newWorld;
}

Basically, it's the IO monad but for emotions. We call this construct the EIO monad.

When should I require emotions?

You can require emotions at any point. One common use case is to include emotions at the top of a file:

import ...
import {despair} from 'emotions';

// 50000 lines of spaghetti code

You can also scope emotions to statements:

...
{
    import {pride} from 'emotions';
    ...
}
...

or even scope emotions to individual expressions:

import emotions from 'emotions';

...

var a = emotions.stress(1 + 2); // 3

What is the performance impact of emotions?

Depending on the required emotion and your Javascript engine, expect anything between a 2x speedup and a 97% slowdown:

Here's a simple benchmark:

var emotionless = function() {
    return 1 + 2;
};

var withEmotions = function() {
    return emotions.stress(1 + 2);
};

In benchmarks, withEmotions is approximately 80% slower than its emotion free counterpart.