Skip to content

Commit 2ba327d

Browse files
committed
Init
1 parent 4d46e23 commit 2ba327d

File tree

6 files changed

+60
-28
lines changed

6 files changed

+60
-28
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ The list of standard filters Vue.js 1.* adapted for use in Vue.js 2.*
1010
npm install vue2-filters
1111
```
1212

13+
### CommonJS
14+
15+
```js
16+
var Vue = require('Vue');
17+
var Vue2Filters = require('vue2-filters');
18+
Vue.use(Vue2Filters);
19+
```
20+
21+
### AMD
22+
```js
23+
require(['vue','vue2-filters'], function(Vue, Vue2Filters) {
24+
Vue.use(Vue2Filters);
25+
});
26+
```
27+
1328
### Direct include
1429

1530
```html

dist/vue-filters.min.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/vue-filters.js renamed to dist/vue2-filters.js

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
/******/ (function(modules) { // webpackBootstrap
1+
(function webpackUniversalModuleDefinition(root, factory) {
2+
if(typeof exports === 'object' && typeof module === 'object')
3+
module.exports = factory();
4+
else if(typeof define === 'function' && define.amd)
5+
define([], factory);
6+
else {
7+
var a = factory();
8+
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
9+
}
10+
})(this, function() {
11+
return /******/ (function(modules) { // webpackBootstrap
212
/******/ // The module cache
313
/******/ var installedModules = {};
414

@@ -534,20 +544,24 @@ function install(Vue) {
534544
__WEBPACK_IMPORTED_MODULE_0__util_index__["a" /* default */].each(__WEBPACK_IMPORTED_MODULE_3__other_index__, function(value, key) {
535545
Vue.filter(key, value)
536546
})
537-
}
538547

539-
var mixins = {
540-
methods: {
541-
limitBy: __WEBPACK_IMPORTED_MODULE_2__array_index__["a" /* limitBy */],
542-
filterBy: __WEBPACK_IMPORTED_MODULE_2__array_index__["b" /* filterBy */],
543-
orderBy: __WEBPACK_IMPORTED_MODULE_2__array_index__["c" /* orderBy */]
544-
}
548+
Vue.mixin({
549+
methods: {
550+
limitBy: __WEBPACK_IMPORTED_MODULE_2__array_index__["a" /* limitBy */],
551+
filterBy: __WEBPACK_IMPORTED_MODULE_2__array_index__["b" /* filterBy */],
552+
orderBy: __WEBPACK_IMPORTED_MODULE_2__array_index__["c" /* orderBy */]
553+
}
554+
})
545555
}
546556

547-
if(window.Vue) {
557+
if (window.Vue) {
548558
Vue.use(install)
549-
Vue.mixin(mixins)
550-
}
559+
} else if (true) {
560+
module.exports = install
561+
} else if (typeof define === "function" && define.amd) {
562+
define([], function(){ return install })
563+
}
551564

552565
/***/ }
553-
/******/ ]);
566+
/******/ ]);
567+
});

dist/vue2-filters.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
{
22
"name": "vue2-filters",
3-
"version": "0.1.0",
3+
"version": "0.1.2",
44
"description": "The list of standard filters Vue.js 1.* adapted for use in Vue.js 2.*",
5-
"main": "dist/vue-filters.js",
5+
"main": "dist/vue2-filters.js",
66
"scripts": {
7-
"build": "webpack src/index.js dist/vue-filters.min.js --optimize-minimize",
8-
"dev": "webpack src/index.js dist/vue-filters.js --watch",
7+
"build": "webpack src/index.js dist/vue2-filters.min.js --output-library-target umd --optimize-minimize",
8+
"dev": "webpack src/index.js dist/vue2-filters.js --output-library-target umd --watch",
99
"test": "echo \"Error: no test specified\" && exit 1"
1010
},
1111
"keywords": [
1212
"vuejs",
1313
"vue",
1414
"filters",
15-
"vue-filters"
15+
"vue2-filters"
1616
],
1717
"author": "Arhey",
1818
"license": "MIT",

src/index.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,20 @@ function install(Vue) {
1111
util.each(otherFilters, function(value, key) {
1212
Vue.filter(key, value)
1313
})
14-
}
1514

16-
var mixins = {
17-
methods: {
18-
limitBy: arrayFilters.limitBy,
19-
filterBy: arrayFilters.filterBy,
20-
orderBy: arrayFilters.orderBy
21-
}
15+
Vue.mixin({
16+
methods: {
17+
limitBy: arrayFilters.limitBy,
18+
filterBy: arrayFilters.filterBy,
19+
orderBy: arrayFilters.orderBy
20+
}
21+
})
2222
}
2323

24-
if(window.Vue) {
24+
if (window.Vue) {
2525
Vue.use(install)
26-
Vue.mixin(mixins)
27-
}
26+
} else if (typeof exports === "object") {
27+
module.exports = install
28+
} else if (typeof define === "function" && define.amd) {
29+
define([], function(){ return install })
30+
}

0 commit comments

Comments
 (0)