Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mm

Package Overview
Dependencies
Maintainers
5
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mm - npm Package Compare versions

Comparing version 3.2.1 to 3.2.2

LICENSE

5

index.d.ts

@@ -42,2 +42,7 @@ declare function mm(target: any, key: string, prop: any): void;

/**
* spy a function
*/
function spy(mod: any, method: string): void;
/**
* mock return callback(null, data1, data2).

@@ -44,0 +49,0 @@ */

2

index.js

@@ -1,5 +0,3 @@

'use strict';
module.exports = require('./lib/mm');
require('./lib/es6');

@@ -1,3 +0,1 @@

'use strict';
const is = require('is-type-of');

@@ -4,0 +2,0 @@ const sleep = require('ko-sleep');

@@ -1,3 +0,1 @@

'use strict';
const EventEmitter = require('events');

@@ -129,2 +127,7 @@ const is = require('is-type-of');

* @param {Number} timeout, mock async callback timeout, default is 0.
* @param mod
* @param method
* @param error
* @param props
* @param timeout
* @return {mm} this - mm

@@ -143,2 +146,7 @@ */

* @param {Number} timeout, mock async callback timeout, default is 0.
* @param mod
* @param method
* @param error
* @param props
* @param timeout
* @return {mm} this - mm

@@ -157,2 +165,6 @@ */

* @param {Number} timeout, mock async callback timeout, default is 10.
* @param mod
* @param method
* @param datas
* @param timeout
* @return {mm} this - mm

@@ -184,2 +196,6 @@ */

* @param {Number} timeout, mock async callback timeout, default is 0.
* @param mod
* @param method
* @param data
* @param timeout
* @return {mm} this - mm

@@ -197,2 +213,5 @@ */

* @param {Number} [timeout], mock async callback timeout, default is 0.
* @param mod
* @param method
* @param timeout
* @return {mm} this - mm

@@ -208,6 +227,12 @@ */

* @param {String} method, mock module object method name.
* @param mod
* @param method
*/
exports.spy = function(mod, method) {
if (typeof mod[method] !== 'function') throw new Error(`spy target ${method} is not a function`);
mock(mod, method, mod[method]);
const originalFn = mod[method];
const wrap = function proxy() {
return originalFn.apply(this, arguments);
};
mock(mod, method, wrap);
};

@@ -222,2 +247,6 @@

* @param {Object} [props], error properties
* @param mod
* @param method
* @param error
* @param props
*/

@@ -237,2 +266,5 @@ exports.syncError = function(mod, method, error, props) {

* @param {Object} data, return data.
* @param mod
* @param method
* @param data
*/

@@ -250,2 +282,4 @@ exports.syncData = function(mod, method, data) {

* @param {String} method, mock module object method name.
* @param mod
* @param method
*/

@@ -307,2 +341,6 @@ exports.syncEmpty = function(mod, method) {

* @param {Number} [delay], response delay time, default is 10.
* @param url
* @param data
* @param headers
* @param delay
* @return {mm} this - mm

@@ -323,2 +361,6 @@ */

* @param {Number} [delay], response delay time, default is 0.
* @param url
* @param data
* @param headers
* @param delay
* @return {mm} this - mm

@@ -434,2 +476,6 @@ */

* @param {Number} [delay], request error delay time, default is 0.
* @param url
* @param reqError
* @param resError
* @param delay
*/

@@ -447,2 +493,6 @@ exports.http.requestError = function(url, reqError, resError, delay) {

* @param {Number} [delay], request error delay time, default is 0.
* @param url
* @param reqError
* @param resError
* @param delay
*/

@@ -449,0 +499,0 @@ exports.https.requestError = function(url, reqError, resError, delay) {

{
"name": "mm",
"version": "3.2.1",
"version": "3.2.2",
"description": "mock mate, mock http request, fs access and so on.",

@@ -14,4 +14,3 @@ "main": "index.js",

"ci": "npm run lint && egg-bin cov",
"lint": "eslint --fix lib test index.js",
"autod": "autod -w --prefix '^'"
"lint": "eslint --fix lib test index.js"
},

@@ -25,10 +24,8 @@ "dependencies": {

"devDependencies": {
"autod": "^3.1.0",
"chunkstream": "^0.0.1",
"co": "^4.6.0",
"egg-bin": "^1.11.1",
"egg-ci": "^2.2.0",
"egg-bin": "^5.5.0",
"enable": "^3.4.0",
"eslint": "^6.8.0",
"eslint-config-egg": "^8.0.1",
"eslint": "^8.28.0",
"eslint-config-egg": "^12.1.0",
"node-patch": "*",

@@ -38,3 +35,3 @@ "pedding": "^1.1.0",

"thunkify-wrap": "^1.0.4",
"urllib": "^2.34.2",
"urllib": "^3.5.1",
"uuid": "^3.4.0"

@@ -59,4 +56,4 @@ },

},
"author": "fengmk2 <fengmk2@gmail.com> (https://fengmk2.com)",
"author": "fengmk2 <fengmk2@gmail.com> (https://github.com/fengmk2)",
"license": "MIT"
}

@@ -5,5 +5,4 @@ mm

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Node.js CI](https://github.com/node-modules/mm/actions/workflows/nodejs.yml/badge.svg)](https://github.com/node-modules/mm/actions/workflows/nodejs.yml)
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![npm download][download-image]][download-url]

@@ -13,8 +12,4 @@

[npm-url]: https://npmjs.org/package/mm
[travis-image]: https://img.shields.io/travis/node-modules/mm.svg?style=flat-square
[travis-url]: https://travis-ci.org/node-modules/mm
[codecov-image]: https://codecov.io/github/node-modules/mm/coverage.svg?branch=master
[codecov-url]: https://codecov.io/github/node-modules/mm?branch=master
[david-image]: https://img.shields.io/david/node-modules/mm.svg?style=flat-square
[david-url]: https://david-dm.org/node-modules/mm
[download-image]: https://img.shields.io/npm/dm/mm.svg?style=flat-square

@@ -25,4 +20,2 @@ [download-url]: https://npmjs.org/package/mm

__mm@2 only support node v4.0+.__
## Install

@@ -100,18 +93,2 @@

### Support generator function
```js
var foo = {
get: function* () {
return 1;
}
};
mm.data(foo, 'get', 2);
var data = yield* foo.get(); // data should return 2
mm.error(foo, 'get', 'error boom');
yield* foo.get(); // should throw error
```
## API

@@ -334,25 +311,2 @@

```
This software is licensed under the MIT License.
Copyright (C) 2012 - 2014 fengmk2 <fengmk2@gmail.com>
Copyright (C) 2015 - present node-modules
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```
[MIT](LICENSE)
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