New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

co-mocha

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

co-mocha - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

27

co-mocha.js

@@ -1,5 +0,4 @@

var co = require('co');
var path = require('path');
var Promise = require('bluebird');
var isGenerator = require('is-generator');
var co = require('co');
var path = require('path');
var isGenFn = require('is-generator').fn;

@@ -26,19 +25,5 @@ /**

Runnable.prototype.run = function (fn) {
var func = this.fn;
if (this.sync) {
this.fn = function () {
var result = func.call(this);
// If the function returned a generator, pass the object to `co` and
// transform the result into a promise for compatibility with `mocha`.
// We are checking the function return since not all transpilers
// (looking at you, traceur) provide a method for detecting generator
// functions but all will return generator-like objects.
if (isGenerator(result)) {
return Promise.promisify(co(result), this)();
}
return result;
};
if (isGenFn(this.fn)) {
this.fn = co(this.fn);
this.sync = !(this.async = true);
}

@@ -45,0 +30,0 @@

{
"name": "co-mocha",
"version": "1.0.0",
"version": "1.0.1",
"description": "Enable support for generators in Mocha tests",

@@ -30,9 +30,9 @@ "main": "co-mocha.js",

"devDependencies": {
"bluebird": "^2.3.2",
"istanbul": "git://github.com/gotwarlost/istanbul#harmony",
"mocha": "^1.18.2",
"regenerator": "^0.4.7",
"regenerator": "^0.4.12",
"traceur": "0.0.58"
},
"dependencies": {
"bluebird": "^2.3.0",
"co": "3.x",

@@ -39,0 +39,0 @@ "is-generator": "^1.0.0"

/* global describe, it */
var mocha = require('mocha');
var assert = require('assert');
var traceur = require('traceur');
var Promise = require('bluebird');
var Bluebird = require('bluebird');
var regenerator = require('regenerator');
var mocha = require('mocha');
var coMocha = require('./')(mocha);

@@ -12,5 +12,4 @@ var Runnable = mocha.Runnable;

/**
* Wait a certain amount of time before proceeding to the callback.
* Thunkify a function for `process.nextTick`.
*
* @param {Number} ms
* @return {Function}

@@ -47,3 +46,3 @@ */

var test = new Runnable('promise', function () {
return new Promise(function (resolve) {
return new Bluebird(function (resolve) {
return nextTick()(resolve);

@@ -58,3 +57,3 @@ });

var test = new Runnable('promise', function () {
return new Promise(function (resolve, reject) {
return new Bluebird(function (resolve, reject) {
return nextTick()(function () {

@@ -73,4 +72,2 @@ return reject(new Error('You promised me'));

});
it('should fail with falsy');
});

@@ -77,0 +74,0 @@

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