# node-mixin

> copy properties from an object to another

Latest version **1.0.0** (published 2013-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-mixin
pnpm add node-mixin
yarn add node-mixin
bun add node-mixin
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2013-11-06 |
| First published | 2013-11-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Akira Wu |
| Maintainers | akira_cn |

## Links

- npm: https://www.npmjs.com/package/node-mixin
- Repository: https://github.com/akira-cn/mixin.js
- Issues: https://github.com/akira-cn/mixin.js/issues
- npm.io page: https://npm.io/package/node-mixin

## Recent versions

- 1.0.0 (latest) — 2013-11-06

## README

## 使用说明

### 外链形式

```html
<script src="{{src}}"></script>

<script>
    function A(options){
    	this.options = mixin(options, defaultOptions);
    }
</script>
```

### 模块加载形式

```html
<script>
    require(['{{module}}'], function(mixin) {
	    function A(options){
	    	this.options = mixin(options, defaultOptions);
	    }
    });
</script>
```

## 文档参考

### *mixin(des, src)*

将src上的属性复制到des上

默认复制des上不存在而src上存在的属性，会忽略掉des上已经存在的属性

### *mixin(des, src, true)*

将src上的属性复制到des上并覆盖des上原有的属性

等价于 *jQuery.extend(des, src)*

### *mixin(des, src, map)*

依次遍历src每一个属性，对每一个属性触发一次map操作，将map的结果赋给des

如果map返回undefeind，des上的对应属性将被delete

```js
var a = {x:{y:1, z:3}};
mixin(a, {x:{y:2}, z:2}, function(a,b){
	try{
		return mixin(a,b, arguments.callee)
	}catch(ex){
		return b
	}
});
//实现了深拷贝，等价于 jQuery.extend(true, a, {x:{y:2}, z:2});
```

---
_Source: https://npm.io/package/node-mixin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
