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

tabular

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tabular - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

43

index.js

@@ -22,6 +22,45 @@ 'use strict';

Tabular.prototype.push = function (row) {
this._rows.push(row);
Tabular.prototype.push = function () {
Array.prototype.push.apply(this._rows, arguments);
};
var sortTypes = {
first: function (a, b) {
if (a[0] < b[0]) {
return -1;
}
if (a[0] > b[0]) {
return 1;
}
return 0;
},
second: function (a, b) {
if (a[1] < b[1]) {
return -1;
}
if (a[1] > b[1]) {
return 1;
}
return 0;
}
};
Tabular.prototype.sort = function (type) {
if (!type) {
type = 'first';
}
if (!sortTypes[type]) {
throw new Error('Invalid sort type');
}
this._rows = this._rows.sort(sortTypes[type]);
return this;
};
Tabular.prototype.get = function () {

@@ -28,0 +67,0 @@ if (this._rows.length === 0) {

2

package.json
{
"name": "tabular",
"version": "0.0.1",
"version": "0.0.2",
"description": "Create fluid lists in which the first column adapts to the content",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -25,2 +25,15 @@ node-tabular

console.log(tab.get());
```
```
### Sorting
You can also sort the list by the `first` or `second` column like so:
```js
// ...
console.log(tab.sort('second').get());
```
Note that once you sort the list, the original order is lost.
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