Skip to content

Commit

Permalink
Scaffold: Normalize repository
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed May 14, 2018
1 parent 0a216e0 commit 571e4a1
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 30 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf

[*.md]
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "@phated/iceddev/es5"
"extends": "gulp"
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
sudo: false
language: node_js
node_js:
- 'iojs'
- '10'
- '8'
- '6'
- '4'
- '0.12'
- '0.10'
before_install:
- 'npm install -g npm' # update npm before install for scopes
after_script:
- npm run coveralls
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Blaine Bublitz
Copyright (c) 2014 Blaine Bublitz <blaine.bublitz@gmail.com> and Eric Schoffstall <yo@contra.io>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
26 changes: 26 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# http://www.appveyor.com/docs/appveyor-yml
# http://www.appveyor.com/docs/lang/nodejs-iojs

environment:
matrix:
# node.js
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"

install:
- ps: Install-Product node $env:nodejs_version
- npm install

test_script:
- node --version
- npm --version
- cmd: npm test

build: off

# build version format
version: "{build}"
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ var EventEmitter = require('events').EventEmitter;
var sparklesNamespace = 'store@sparkles';
var defaultNamespace = 'default';

function getStore(){
function getStore() {
var store = global[sparklesNamespace];

if(!store){
if (!store) {
store = global[sparklesNamespace] = {};
}

return store;
}

function getEmitter(namespace){
function getEmitter(namespace) {

var store = getStore();

namespace = namespace || defaultNamespace;

var ee = store[namespace];

if(!ee){
if (!ee) {
ee = store[namespace] = new EventEmitter();
ee.setMaxListeners(0);
ee.remove = function remove(){
ee.remove = function remove() {
ee.removeAllListeners();
delete store[namespace];
};
Expand All @@ -35,7 +35,7 @@ function getEmitter(namespace){
return ee;
}

function exists(namespace){
function exists(namespace) {
var store = getStore();

return !!(store[namespace]);
Expand Down
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
"name": "sparkles",
"version": "1.0.0",
"description": "Namespaced global event emitter",
"author": "Blaine Bublitz <blaine@iceddev.com> (http://iceddev.com/)",
"contributors": [],
"repository": "phated/sparkles",
"author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)",
"contributors": [
"Blaine Bublitz <blaine.bublitz@gmail.com>"
],
"repository": "gulpjs/sparkles",
"license": "MIT",
"engines": {
"node": ">= 0.10"
Expand All @@ -23,12 +25,12 @@
},
"dependencies": {},
"devDependencies": {
"eslint": "^2.0.0",
"eslint-config-gulp": "github:gulpjs/eslint-config-gulp",
"expect": "^1.19.0",
"eslint": "^2.13.0",
"eslint-config-gulp": "^3.0.1",
"expect": "^1.20.2",
"istanbul": "^0.4.3",
"istanbul-coveralls": "^1.0.3",
"mocha": "^3.5.0"
"mocha": "^3.5.3"
},
"keywords": [
"ee",
Expand Down
3 changes: 3 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "gulp/test"
}
4 changes: 2 additions & 2 deletions test/exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ var expect = require('expect');

var sparkles = require('../');

describe('sparkles.exists()', function(){
describe('sparkles.exists()', function() {

it('checks if a namespace has been defined', function(done){
it('checks if a namespace has been defined', function(done) {
expect(sparkles.exists('test')).toBe(false);
var ee = sparkles('test');
expect(sparkles.exists('test')).toBe(true);
Expand Down
10 changes: 5 additions & 5 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ var expect = require('expect');

var sparkles = require('../');

function noop(){}
function noop() {}

describe('sparkles()', function(){
describe('sparkles()', function() {

var ee;

beforeEach(function(done){
beforeEach(function(done) {
ee = sparkles();
done();
});

afterEach(function(done){
afterEach(function(done) {
ee.remove();
done();
});
Expand All @@ -30,7 +30,7 @@ describe('sparkles()', function(){
done();
});

it('removes the event emitter from the store when remove is called', function(done){
it('removes the event emitter from the store when remove is called', function(done) {
ee.on('test', noop);
ee.remove();
expect(global['store@sparkles']).toNotIncludeKey('default');
Expand Down
10 changes: 5 additions & 5 deletions test/namespace.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ var expect = require('expect');

var EventEmitter = require('events').EventEmitter;

describe('namespace', function(){
describe('namespace', function() {

beforeEach(function(done){
beforeEach(function(done) {
global['store@sparkles'] = {};
done();
});

afterEach(function(done){
afterEach(function(done) {
delete global['store@sparkles'];
done();
});

it('should use an EE from sparkles namespace if it already exists', function(done){
it('should use an EE from sparkles namespace if it already exists', function(done) {
var ee = global['store@sparkles'].default = new EventEmitter();
ee.custom = 'ee';

Expand All @@ -26,7 +26,7 @@ describe('namespace', function(){
done();
});

it('should allow custom namespaces', function(done){
it('should allow custom namespaces', function(done) {
var ee = global['store@sparkles'].customNamespace = new EventEmitter();
ee.custom = true;

Expand Down

0 comments on commit 571e4a1

Please sign in to comment.