Socket
Socket
Sign inDemoInstall

ampersand-collection-sort-mixin

Package Overview
Dependencies
13
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ampersand-collection-sort-mixin

A mixin to provide simple ascending/descending sorting


Version published
Maintainers
1
Install size
115 kB
Created

Readme

Source

ampersand-collection-rest-mixin

A mixin for extending ampersand-collection with the ability to sort by multiple properties, and ascending/descending. The sorting is performed when adding new models to the collection, or when the sort() method is called.

install

npm install ampersand-collection-sort-mixin

usage

The mixin uses two properties stored in session properties:

  • sortProps - Array of strings, or string. An array of the property names to sort the collection by. If just one, it can be just a string.
  • sortDescending - Boolean. Set to true to sort descending. Default is false (ascending)

example

var Collection = require('ampersand-collection');
var sortMixin = require('ampersand-collection-sort-mixin');


module.exports = Collection.extend(sortMixin, {
    session: {
        sortProps: ['lastname', 'firstname'],
        sortDescending: true
    },

});

credits

The main nugget of this code came from the base collection sort() method.

license

MIT

Keywords

FAQs

Last updated on 15 Dec 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc