templates
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -965,2 +965,3 @@ /*! | ||
utils.extend(obj, locals); | ||
obj.view = view; | ||
return obj; | ||
@@ -967,0 +968,0 @@ }, |
@@ -6,3 +6,3 @@ 'use strict'; | ||
var utils = require('./utils'); | ||
var Views = require('./views'); | ||
var Group = require('./group'); | ||
@@ -15,10 +15,11 @@ function List(options) { | ||
this.define('Item', this.options.Item || require('vinyl')); | ||
this.define('Views', this.options.Views || require('./views')); | ||
this.define('Item', this.options.Item || require('./view')); | ||
this.items = []; | ||
this.keys = []; | ||
if (options instanceof Views) { | ||
if (options instanceof this.Views) { | ||
this.addItems(options.views); | ||
} | ||
} | ||
}; | ||
@@ -109,3 +110,3 @@ Base.extend(List); | ||
// group the `items` and return the result | ||
return fn.apply(fn, args); | ||
return new Group(fn.apply(fn, args)); | ||
}; | ||
@@ -149,2 +150,26 @@ | ||
/** | ||
* Paginate all list `items` with the given options, | ||
* See [paginationator][] for the full range of available features and options. | ||
* | ||
* ```js | ||
* var list = new List(); | ||
* list.addItems(...); | ||
* var pages = list.paginate({limit: 5}); | ||
* ``` | ||
* @return {Object} Returns the paginated items. | ||
* @api public | ||
*/ | ||
List.prototype.paginate = function() { | ||
var args = [].slice.call(arguments); | ||
var fn = utils.paginationator; | ||
// Make `items` the first argument for paginationator | ||
args.unshift(this.items.slice()); | ||
// paginate the `items` and return the pages | ||
return fn.apply(fn, args).pages; | ||
}; | ||
utils.define(List.prototype, 'count', { | ||
@@ -159,2 +184,6 @@ get: function() { | ||
/** | ||
* Expose `List` | ||
*/ | ||
module.exports = List; |
@@ -14,2 +14,3 @@ 'use strict'; | ||
lazy('is-buffer'); | ||
lazy('paginationator'); | ||
lazy('array-sort', 'sortBy'); | ||
@@ -101,19 +102,3 @@ lazy('group-array', 'groupBy'); | ||
/** | ||
* CLASS UTILS | ||
* ------------------------ | ||
*/ | ||
utils.copyDescriptor = function copyDescriptor(receiver, provider, key) { | ||
var val = utils.getDescriptor(provider, key); | ||
if (val) utils.define(receiver, key, val); | ||
}; | ||
utils.getDescriptor = function getDescriptor(provider, key) { | ||
return Object.getOwnPropertyDescriptor(provider, key); | ||
}; | ||
/** | ||
* OBJECT / ARRAY / TYPE UTILS | ||
@@ -154,3 +139,13 @@ * -------------------------------- | ||
/** | ||
* Returns true if an array have the given element | ||
* @return {Boolean} | ||
*/ | ||
utils.has = function has(keys, key) { | ||
return keys.indexOf(key) > -1; | ||
}; | ||
/** | ||
* Return true if the given value is an object. | ||
* @return {Boolean} | ||
*/ | ||
@@ -162,2 +157,3 @@ | ||
}; | ||
/** | ||
@@ -343,3 +339,3 @@ * Return true if the given value is a stream. | ||
utils.option = function(app) { | ||
utils.option = function option(app) { | ||
utils.define(app, 'option', function(key, value) { | ||
@@ -346,0 +342,0 @@ if (typeof key === 'string') { |
'use strict'; | ||
var Base = require('base-methods'); | ||
var Vinyl = require('vinyl'); | ||
var Base = require('base-methods'); | ||
var Stream = require('stream'); | ||
var cloneStats = require('clone-stats'); | ||
var Stream = require('stream'); | ||
var inherit = require('./inherit'); | ||
var utils = require('./utils'); | ||
@@ -54,3 +53,3 @@ | ||
Base.extend(View); | ||
inherit(View, Vinyl); | ||
Base.inherit(View, Vinyl); | ||
@@ -57,0 +56,0 @@ /** |
@@ -9,2 +9,3 @@ 'use strict'; | ||
this.options = options || {}; | ||
this.define('List', this.options.List || require('./list')); | ||
this.define('View', this.options.View || require('./view')); | ||
@@ -14,2 +15,6 @@ utils.renameKey(this); | ||
this.views = {}; | ||
if (options instanceof this.List) { | ||
this.addList(options.items); | ||
} | ||
} | ||
@@ -123,2 +128,6 @@ | ||
/** | ||
* Expose `Views` | ||
*/ | ||
module.exports = Views; |
{ | ||
"name": "templates", | ||
"description": "System for creating and managing template collections, and rendering templates with any node.js template engine. Can be used as the basis for creating a static site generator or blog framework.", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"homepage": "https://github.com/jonschlinkert/templates", | ||
@@ -25,3 +25,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"array-sort": "^0.1.1", | ||
"base-methods": "^0.2.3", | ||
"base-methods": "^0.2.4", | ||
"clone": "^1.0.2", | ||
@@ -46,2 +46,3 @@ "clone-stats": "0.0.1", | ||
"object.reduce": "^0.1.7", | ||
"paginationator": "^0.1.1", | ||
"template-error": "^0.1.2", | ||
@@ -65,3 +66,2 @@ "vinyl": "^0.5.3" | ||
"should": "*", | ||
"stringify-object": "jonschlinkert/stringify-object", | ||
"swig": "^1.4.2", | ||
@@ -68,0 +68,0 @@ "template-helpers": "^0.3.4" |
@@ -343,2 +343,2 @@ # templates [![NPM version](https://badge.fury.io/js/templates.svg)](http://badge.fury.io/js/templates) | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 09, 2015._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 10, 2015._ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67702
16
1930
24
343
+ Addedpaginationator@^0.1.1
+ Addedpaginationator@0.1.4(transitive)
Updatedbase-methods@^0.2.4