emotions

0.0.1 • Public • Published
$ 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.

Dependents (0)

Package Sidebar

Install

npm i emotions

Weekly Downloads

35

Version

0.0.1

License

MIT

Last publish

Collaborators

  • mattbierner