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

angular2-pipes

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular2-pipes - npm Package Compare versions

Comparing version 1.4.2 to 1.4.3

2

package.json
{
"name": "angular2-pipes",
"version": "1.4.2",
"version": "1.4.3",
"author": "Dan Revah",

@@ -5,0 +5,0 @@ "description": "Useful angular2 pipes",

import { PipeTransform } from '@angular/core';
export declare class OrderByPipe implements PipeTransform {
transform(input: any, config?: any): any[];
static orderCompare(prop: string, asc: boolean, a: any, b: any): any;
static extractFromConfig(config: any): any[];
private static simpleSort(a, b);
private static orderCompare(prop, asc, a, b);
private static extractFromConfig(config);
}

@@ -30,4 +30,4 @@ "use strict";

switch (sign) {
case '+': return out.sort();
case '-': return out.sort().reverse();
case '+': return out.sort(OrderByPipe.simpleSort.bind(this));
case '-': return out.sort(OrderByPipe.simpleSort.bind(this)).reverse();
}

@@ -38,8 +38,9 @@ }

// default sort by value
return out.sort(function (a, b) {
return helpers_1.isString(a) && helpers_1.isString(b)
? a.toLowerCase().localeCompare(b.toLowerCase())
: a - b;
});
return out.sort(OrderByPipe.simpleSort.bind(this));
};
OrderByPipe.simpleSort = function (a, b) {
return helpers_1.isString(a) && helpers_1.isString(b)
? a.toLowerCase().localeCompare(b.toLowerCase())
: a - b;
};
OrderByPipe.orderCompare = function (prop, asc, a, b) {

@@ -46,0 +47,0 @@ var first = helpers_1.extractDeepPropertyByMapKey(a, prop), second = helpers_1.extractDeepPropertyByMapKey(b, prop);

@@ -1,1 +0,1 @@

[{"__symbolic":"module","version":3,"metadata":{"OrderByPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"orderBy"}]}],"members":{"transform":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"OrderByPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"orderBy"}]}],"members":{"transform":[{"__symbolic":"method"}]}}}}]
[{"__symbolic":"module","version":3,"metadata":{"OrderByPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"orderBy"}]}],"members":{"transform":[{"__symbolic":"method"}]},"statics":{"simpleSort":{"__symbolic":"function","parameters":["a","b"],"value":{"__symbolic":"if","condition":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../helpers/helpers","name":"isString"},"arguments":[{"__symbolic":"reference","name":"a"}]},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../helpers/helpers","name":"isString"},"arguments":[{"__symbolic":"reference","name":"b"}]}},"thenExpression":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"a"},"member":"toLowerCase"}},"member":"localeCompare"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"b"},"member":"toLowerCase"}}]},"elseExpression":{"__symbolic":"binop","operator":"-","left":{"__symbolic":"reference","name":"a"},"right":{"__symbolic":"reference","name":"b"}}}}}}}},{"__symbolic":"module","version":1,"metadata":{"OrderByPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"orderBy"}]}],"members":{"transform":[{"__symbolic":"method"}]},"statics":{"simpleSort":{"__symbolic":"function","parameters":["a","b"],"value":{"__symbolic":"if","condition":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../helpers/helpers","name":"isString"},"arguments":[{"__symbolic":"reference","name":"a"}]},"right":{"__symbolic":"call","expression":{"__symbolic":"reference","module":"../helpers/helpers","name":"isString"},"arguments":[{"__symbolic":"reference","name":"b"}]}},"thenExpression":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"a"},"member":"toLowerCase"}},"member":"localeCompare"},"arguments":[{"__symbolic":"call","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"b"},"member":"toLowerCase"}}]},"elseExpression":{"__symbolic":"binop","operator":"-","left":{"__symbolic":"reference","name":"a"},"right":{"__symbolic":"reference","name":"b"}}}}}}}}]

@@ -17,2 +17,13 @@ import {OrderByPipe} from './order-by';

it ('should return dates in order asc', () => {
const a = new Date();
const b = new Date();
expect(pipe.transform([a, b], '+')).toEqual([a, b]);
});
it ('should return numbers in order asc', () => {
const numbers = [0, -1, 345, 1234, 1337, -3];
expect(pipe.transform(numbers, '+')).toEqual([-3, -1, 0, 345, 1234, 1337]);
});
it('should not do anything in-case of not an array', () => {

@@ -19,0 +30,0 @@ expect(pipe.transform('foo')).toEqual('foo');

@@ -34,4 +34,4 @@ import {PipeTransform, Pipe} from '@angular/core';

switch (sign) {
case '+': return out.sort();
case '-': return out.sort().reverse();
case '+': return out.sort(OrderByPipe.simpleSort.bind(this));
case '-': return out.sort(OrderByPipe.simpleSort.bind(this)).reverse();
}

@@ -44,10 +44,12 @@ }

// default sort by value
return out.sort((a, b) => {
return isString(a) && isString(b)
? a.toLowerCase().localeCompare(b.toLowerCase())
: a - b;
});
return out.sort(OrderByPipe.simpleSort.bind(this));
}
static orderCompare(prop: string, asc: boolean, a: any, b: any) {
private static simpleSort(a: any, b: any) {
return isString(a) && isString(b)
? a.toLowerCase().localeCompare(b.toLowerCase())
: a - b;
}
private static orderCompare(prop: string, asc: boolean, a: any, b: any) {
const first = extractDeepPropertyByMapKey(a, prop),

@@ -70,3 +72,3 @@ second = extractDeepPropertyByMapKey(b, prop);

static extractFromConfig(config: any) {
private static extractFromConfig(config: any) {
const sign = config.substr(0, 1);

@@ -73,0 +75,0 @@ const prop = config.replace(/^[-+]/, '');

Sorry, the diff of this file is not supported yet

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