Socket
Socket
Sign inDemoInstall

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.3.0 to 3.4.0

5

index.d.ts

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

/**
* mock return data with Symbol.asyncDispose method
*/
function dataWithAsyncDispose(mod: any, method: string, data: object, timeout?: number): MockMate;
/**
* mock return callback(null, null).

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

@@ -46,2 +46,12 @@ const is = require('is-type-of');

mm.dataWithAsyncDispose = function(mod, method, data, timeout) {
data = {
...data,
async [Symbol.asyncDispose]() {
// do nothing
},
};
return mm.data(mod, method, data, timeout);
};
const mockError = mm.error;

@@ -48,0 +58,0 @@ mm.error = function(mod, method, error, props, timeout) {

20

package.json
{
"name": "mm",
"version": "3.3.0",
"version": "3.4.0",
"description": "mock mate, mock http request, fs access and so on.",

@@ -12,5 +12,7 @@ "main": "index.js",

"scripts": {
"test": "npm run lint && egg-bin test",
"ci": "npm run lint && egg-bin cov",
"lint": "eslint --fix lib test index.js"
"test": "npm run lint && egg-bin test --ts false",
"test-ts": "egg-bin test --ts true",
"ci": "npm run lint && egg-bin cov --ts false && npm run test-ts",
"lint": "eslint --fix lib test index.js",
"contributor": "git-contributor"
},

@@ -23,10 +25,16 @@ "dependencies": {

"devDependencies": {
"@eggjs/tsconfig": "^1.3.3",
"@hazae41/symbol-dispose-polyfill": "^1.0.2",
"@types/mocha": "^10.0.6",
"@types/node": "^20.10.4",
"chunkstream": "^0.0.1",
"co": "^4.6.0",
"egg-bin": "^6.4.0",
"eslint": "^8.28.0",
"eslint-config-egg": "^12.1.0",
"eslint": "^8.55.0",
"eslint-config-egg": "^12.0.0",
"git-contributor": "^2.1.5",
"pedding": "^1.1.0",
"should": "^13.2.3",
"thunkify-wrap": "^1.0.4",
"typescript": "^5.3.3",
"urllib": "^3.5.1"

@@ -33,0 +41,0 @@ },

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

mm
=======
# mm, mock mate

@@ -21,3 +20,3 @@ [![NPM version][npm-image]][npm-url]

```bash
$ npm install mm --save-dev
npm install mm --save-dev
```

@@ -149,2 +148,34 @@

### .dataWithAsyncDispose(module, propertyName, promiseResolveArg)
Support [Symbol.asyncDispose](https://www.totaltypescript.com/typescript-5-2-new-keyword-using)
```js
mm.dataWithAsyncDispose(locker, 'tryLock', {
locked: true,
});
// equals
locker.tryLock = async () => {
return {
locked: true,
[Symbol.asyncDispose](): async () => {
// do nothing
},
};
}
```
Run test with `await using` should work:
```js
mm.dataWithAsyncDispose(locker, 'tryLock', {
locked: true,
});
await using lock = await locker.tryLock('foo-key');
assert.equal(lock.locked, true);
```
### .empty(module, propertyName)

@@ -310,1 +341,14 @@

[MIT](LICENSE)
<!-- GITCONTRIBUTOR_START -->
## Contributors
|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/985607?v=4" width="100px;"/><br/><sub><b>dead-horse</b></sub>](https://github.com/dead-horse)<br/>|[<img src="https://avatars.githubusercontent.com/u/1147375?v=4" width="100px;"/><br/><sub><b>alsotang</b></sub>](https://github.com/alsotang)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/32174276?v=4" width="100px;"/><br/><sub><b>semantic-release-bot</b></sub>](https://github.com/semantic-release-bot)<br/>|[<img src="https://avatars.githubusercontent.com/u/4635838?v=4" width="100px;"/><br/><sub><b>gemwuu</b></sub>](https://github.com/gemwuu)<br/>|
| :---: | :---: | :---: | :---: | :---: | :---: |
|[<img src="https://avatars.githubusercontent.com/u/7971415?v=4" width="100px;"/><br/><sub><b>paranoidjk</b></sub>](https://github.com/paranoidjk)<br/>|[<img src="https://avatars.githubusercontent.com/u/2972143?v=4" width="100px;"/><br/><sub><b>nightink</b></sub>](https://github.com/nightink)<br/>|[<img src="https://avatars.githubusercontent.com/u/6897780?v=4" width="100px;"/><br/><sub><b>killagu</b></sub>](https://github.com/killagu)<br/>|[<img src="https://avatars.githubusercontent.com/u/9213756?v=4" width="100px;"/><br/><sub><b>gxkl</b></sub>](https://github.com/gxkl)<br/>|[<img src="https://avatars.githubusercontent.com/u/2170848?v=4" width="100px;"/><br/><sub><b>iyuq</b></sub>](https://github.com/iyuq)<br/>|[<img src="https://avatars.githubusercontent.com/u/227713?v=4" width="100px;"/><br/><sub><b>atian25</b></sub>](https://github.com/atian25)<br/>|
[<img src="https://avatars.githubusercontent.com/u/2748884?v=4" width="100px;"/><br/><sub><b>xavierchow</b></sub>](https://github.com/xavierchow)<br/>|[<img src="https://avatars.githubusercontent.com/u/5856440?v=4" width="100px;"/><br/><sub><b>whxaxes</b></sub>](https://github.com/whxaxes)<br/>
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sat Dec 09 2023 11:34:46 GMT+0800`.
<!-- GITCONTRIBUTOR_END -->
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