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

artsy-backbone-mixins

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

artsy-backbone-mixins - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

lib/a_to_z.coffee

2

package.json
{
"name": "artsy-backbone-mixins",
"version": "0.0.7",
"version": "0.0.8",
"description": "A library of Backbone mixins that DRY up some common domain logic and Artsy API rabbit holes..",

@@ -5,0 +5,0 @@ "keywords": [

@@ -105,3 +105,3 @@ # artsy-backbone-mixins

class Artwork extends Backbone.Model
class Artworks extends Backbone.Collection

@@ -130,2 +130,60 @@ _.extend @prototype, Fetch(ARTSY_URL)

## AToZ
````coffeescript
{ Fetch } = require 'artsy-backbone-mixins'
{ AToZ } = require('sharify').data
class Artworks extends Backbone.Collection
_.extend @prototype, AToZ
````
### groupByAlpha
Sorts a collection groupped alphabetically based on the `alphaSortKey` function on the model.
Sample output:
````
{
'0-9': [ model_instance, model_instance, model_instance ],
A: [ model_instance, model_instance, model_instance ],
// ...
Z: [ model_instance, model_instance, model_instance ]
}
````
````coffeescript
artworks.alphaSortKey = -> @get 'sortable_id'
artworks.groupByAlpha()
````
### groupByAlphaWithColumns
Groups collection output in a format suitable for rendering in an A-Z list with a specified number of columns.
Sample output:
````
[
{ letter: '0-9', columns: [ ... ] },
{ letter: 'A', columns: [ ... ] },
...
{ letter: 'Z', columns: [ ... ] }
]
// Each column is a 2D array of objects with `href`, and `name` properties:
columns: [
[ { href: '...', name: '...' }, ... { href: '...', name: '...' } ],
[ { href: '...', name: '...' }, ... { href: '...', name: '...' } ],
[ { href: '...', name: '...' }, ... { href: '...', name: '...' } ]
]
````
````coffeescript
artworks.alphaSortKey = -> @get 'sortable_id'
artworks.groupByAlpha()
````
## Contributing

@@ -132,0 +190,0 @@

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