New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apparel-sorter

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apparel-sorter

ApparelSorter.js is a set of functions written in JavaScript that provide sorting for apparel sizes such as XS, S, M, L. It can also sort numeric sizes such as 12, 14, 16W, 18W, etc.

0.1.3
Source
npm
Version published
Weekly downloads
922
-12.61%
Maintainers
1
Weekly downloads
 
Created
Source

ApparelSorter.js

ApparelSorter.js is a set of functions written in JavaScript that provide functionality for sorting apparel sizes such as XS, S, M, L. It can also sort numeric sizes such as 12, 14, 16W, 18W, etc.

Suggested Use

ApparelSorter.js can be helpful in e-commerce applications or with any system where apparel data needs to be displayed with the sizes listed in correct order.

Usage

To simply sort an array of sizes, you can call the sortSizes() function.

var apparelSorter = require('apparel-sorter');
var sorted = apparelSorter.sortSizes(["XL", "L", "S", "M", "XS"]); // returns ["XS","S","M","L","XL"]

You can also return the sort index. The sort index could then, for example, be stored in a database for easy sorting in SQL.

var sizeIndex = apparelSorter.sizeIndex("XS"); // returns a number

Installation

Using npm is the preferred and easiest way to install.

npm install apparel-sorter

Testing

This project uses Mocha to run the tests included with the project. You can run the tests by simply navigation to the node_modules/apparel-sorter folder and typing one of the below commands

$ npm test
$ mocha

License

Please read the License.txt file included with this distribution.

FAQs

Package last updated on 05 Jun 2015

Did you know?

Socket

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