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

paginationator

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paginationator - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

1

index.js

@@ -10,3 +10,2 @@ /*!

var utils = require('./lib/utils');
var Pages = require('./lib/pages');

@@ -13,0 +12,0 @@ var Page = require('./lib/page');

32

lib/page.js
'use strict';
var Base = require('base-methods');
var utils = require('./utils');
var define = require('define-property');

@@ -17,9 +16,10 @@ /**

function Page (page) {
Base.call(this, page);
this.init();
function Page(page) {
if (!page) page = {};
for (var key in page) {
this[key] = page[key];
}
this.initPage();
}
Base.extend(Page);
/**

@@ -29,3 +29,3 @@ * Initialize default properties

Page.prototype.init = function() {
Page.prototype.initPage = function() {
this.idx = (typeof this.idx === 'undefined') ? 0 : this.idx;

@@ -40,4 +40,4 @@ this.total = (typeof this.total === 'undefined') ? 1 : this.total;

utils.define(Page.prototype, 'isFirst', {
get: function () {
define(Page.prototype, 'isFirst', {
get: function() {
return this.idx === 0;

@@ -51,4 +51,4 @@ }

utils.define(Page.prototype, 'isLast', {
get: function () {
define(Page.prototype, 'isLast', {
get: function() {
return this.idx === (this.total - 1);

@@ -62,4 +62,4 @@ }

utils.define(Page.prototype, 'hasPrevious', {
get: function () {
define(Page.prototype, 'hasPrevious', {
get: function() {
return !this.isFirst;

@@ -73,4 +73,4 @@ }

utils.define(Page.prototype, 'hasNext', {
get: function () {
define(Page.prototype, 'hasNext', {
get: function() {
return !this.isLast;

@@ -77,0 +77,0 @@ }

'use strict';
var Base = require('base-methods');
var define = require('define-property');
var Page = require('./page');
var utils = require('./utils');

@@ -18,28 +17,15 @@ /**

function Pages (pages) {
Base.call(this);
this.init(pages);
}
Base.extend(Pages);
/**
* Initialize this array of `pages`
*
* @param {Array} `pages` Optional array of pages
*/
Pages.prototype.init = function(pages) {
function Pages(pages) {
this.pages = [];
if (!pages) return;
if (typeof pages !== 'undefined') {
if (!Array.isArray(pages)) {
throw new TypeError('expected pages to be an Array');
}
pages.forEach(function (page) {
this.addPage(page);
}.bind(this));
if (!Array.isArray(pages)) {
throw new TypeError('expected pages to be an Array');
}
};
pages.forEach(function(page) {
this.addPage(page);
}.bind(this));
}
/**

@@ -74,32 +60,32 @@ * Add a page to the list.

var self = this;
utils.define(page, 'first', {
define(page, 'first', {
enumerable: true,
get: function () {
get: function() {
return self.first && self.first.current;
},
set: function () {}
set: function() {}
});
utils.define(page, 'current', {
define(page, 'current', {
enumerable: true,
get: function () {
get: function() {
return this.idx + 1;
},
set: function () {}
set: function() {}
});
utils.define(page, 'last', {
define(page, 'last', {
enumerable: true,
get: function () {
get: function() {
return self.last && self.last.current;
},
set: function () {}
set: function() {}
});
utils.define(page, 'total', {
define(page, 'total', {
enumerable: true,
get: function () {
get: function() {
return self.total;
},
set: function () {}
set: function() {}
});

@@ -122,4 +108,4 @@

utils.define(Pages.prototype, 'total', {
get: function () {
define(Pages.prototype, 'total', {
get: function() {
return this.pages.length;

@@ -133,4 +119,4 @@ }

utils.define(Pages.prototype, 'first', {
get: function () {
define(Pages.prototype, 'first', {
get: function() {
return this.total > 0 ? this.pages[0] : null;

@@ -144,4 +130,4 @@ }

utils.define(Pages.prototype, 'last', {
get: function () {
define(Pages.prototype, 'last', {
get: function() {
return this.total > 0 ? this.pages[this.total - 1] : null;

@@ -148,0 +134,0 @@ }

{
"name": "paginationator",
"description": "Paginate an array into pages of items.",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/doowb/paginationator",

@@ -13,9 +13,6 @@ "author": "Brian Woodward (https://github.com/doowb)",

"files": [
"lib/",
"index.js"
"index.js",
"lib/"
],
"main": "index.js",
"browser": {
"./lib/utils.js": "./lib/utils-browser.js"
},
"engines": {

@@ -27,21 +24,22 @@ "node": ">=0.10.0"

},
"dependencies": {
"define-property": "^0.2.5"
},
"devDependencies": {
"mocha": "*",
"should": "^7.1.0"
"should": "*"
},
"dependencies": {
"base-methods": "^0.2.3",
"define-property": "^0.2.5",
"lazy-cache": "^0.2.3"
},
"verb": {
"related": {
"list": [
"template",
"assemble",
"base-methods",
"templates",
"assemble",
"verb"
]
}
},
"plugins": [
"gulp-format-md"
]
}
}

@@ -1,5 +0,9 @@

# paginationator [![NPM version](https://badge.fury.io/js/paginationator.svg)](http://badge.fury.io/js/paginationator) [![Build Status](https://travis-ci.org/doowb/paginationator.svg)](https://travis-ci.org/doowb/paginationator)
# paginationator [![NPM version](https://img.shields.io/npm/v/paginationator.svg)](https://www.npmjs.com/package/paginationator) [![Build Status](https://img.shields.io/travis/doowb/paginationator.svg)](https://travis-ci.org/doowb/paginationator)
> Paginate an array into pages of items.
![image](https://cloud.githubusercontent.com/assets/995160/9802527/ca15f300-57e8-11e5-96db-523ea5a0572e.png)
## Install
Install with [npm](https://www.npmjs.com/)

@@ -19,3 +23,3 @@

### [paginationator](index.js#L35)
### [paginationator](index.js#L34)

@@ -42,3 +46,3 @@ Paginate an array with given options and return a `Page` object containing an array of `pages` with pagination information.

### [Page](lib/page.js#L17)
### [Page](lib/page.js#L16)

@@ -57,3 +61,3 @@ Page constructor

### [Pages](lib/pages.js#L18)
### [Pages](lib/pages.js#L17)

@@ -72,3 +76,3 @@ Pages constructor

### [.addPage](lib/pages.js#L56)
### [.addPage](lib/pages.js#L42)

@@ -91,3 +95,3 @@ Add a page to the list.

* [assemble](https://www.npmjs.com/package/assemble): Static site generator for Grunt.js, Yeoman and Node.js. Used by Zurb Foundation, Zurb Ink, H5BP/Effeckt,… [more](https://www.npmjs.com/package/assemble) | [homepage](http://assemble.io)
* [template](https://www.npmjs.com/package/template): Render templates using any engine. Supports, layouts, pages, partials and custom template types. Use template… [more](https://www.npmjs.com/package/template) | [homepage](https://github.com/jonschlinkert/template)
* [base-methods](https://www.npmjs.com/package/base-methods): base-methods is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://www.npmjs.com/package/base-methods) | [homepage](https://github.com/jonschlinkert/base-methods)
* [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine.… [more](https://www.npmjs.com/package/templates) | [homepage](https://github.com/jonschlinkert/templates)

@@ -112,8 +116,8 @@ * [verb](https://www.npmjs.com/package/verb): Documentation generator for GitHub projects. Verb is extremely powerful, easy to use, and is used… [more](https://www.npmjs.com/package/verb) | [homepage](https://github.com/verbose/verb)

+ [github/doowb](https://github.com/doowb)
+ [twitter/doowb](http://twitter.com/doowb)
* [github/doowb](https://github.com/doowb)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 Brian Woodward
Copyright © 2015 [Brian Woodward](https://github.com/doowb)
Released under the MIT license.

@@ -123,2 +127,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on September 10, 2015._
_This file was generated by [verb](https://github.com/verbose/verb) on December 20, 2015._
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