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

@forter/directives

Package Overview
Dependencies
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forter/directives - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

get/index.js

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

## [3.0.2](https://github.com/forter/web-components/compare/@forter/directives@3.0.1...@forter/directives@3.0.2) (2020-01-19)
**Note:** Version bump only for package @forter/directives
## [3.0.1](https://github.com/forter/web-components/compare/@forter/directives@3.0.0...@forter/directives@3.0.1) (2020-01-15)

@@ -8,0 +16,0 @@

4

get/get.js

@@ -9,2 +9,6 @@ /**

const get = (obj, path, defaultValue) => {
if (!path) {
return defaultValue;
}
const travel = regexp => String.prototype.split.call(path, regexp).filter(Boolean).reduce((res, key) => res !== null && res !== undefined ? res[key] : res, obj);

@@ -11,0 +15,0 @@

@@ -7,2 +7,4 @@ export { when } from './when/when.js';

export { DASHCASE_MODULE } from './dashCase/index.js';
export { get } from './get/get.js';
export { GET_MODULE } from './get/index.js';
export { langsConfig, withLangs } from './translate/translate.langs.js';

@@ -15,2 +17,3 @@ export { translate } from './translate/translate.js';

export { CONTAINS_MODULE } from './contains/index.js';
export { orderBy } from './orderBy/orderBy.js';
//# sourceMappingURL=index.js.map

7

package.json
{
"name": "@forter/directives",
"version": "3.0.1",
"version": "3.0.2",
"description": "lit-html directives for Forter Components",

@@ -45,6 +45,5 @@ "main": "index.js",

"lit-element": "^2.1.0",
"lit-html": "^1.1.0",
"lodash-es": "^4.17.11"
"lit-html": "^1.1.0"
},
"gitHead": "441176a1899999c1099f29e78c439dcf042544e7"
"gitHead": "65eec6a4fe17d685427bd44cd2c4878dcf42fe4f"
}

@@ -9,2 +9,5 @@ /**

export const get = (obj, path, defaultValue) => {
if (!path) {
return defaultValue;
}
const travel = regexp =>

@@ -11,0 +14,0 @@ String.prototype.split

@@ -7,1 +7,3 @@ export * from './when';

export * from './contains';
export * from './get';
export * from './orderBy';

@@ -5,6 +5,11 @@ /**

* @param {String} key - the field to sort by
* @param {Array} sort - array with direction of sorting
* @return {Array} obj sorted objects
*/
export const orderBy = (obj, key) => {
export const orderBy = (obj, key, sort = ['asc'] ) => {
const [direction] = sort;
if (direction === 'desc') {
return obj.concat().sort((a, b) => (b[key] > a[key]) ? 1 : ((a[key] > b[key]) ? -1 : 0));
}
return obj.concat().sort((a, b) => (a[key] > b[key]) ? 1 : ((b[key] > a[key]) ? -1 : 0));
};

@@ -9,6 +9,7 @@ import { expect, fixture, html } from '@open-wc/testing';

const obj = [{ a: 2 }, { a: 1 }];
const obj = [{ a: 2 }, { a: 3 }, { a: 1 }];
const strings = [{ a: 'b' }, { a: 'c' }, { a: 'a' }];
describe('directives/orderBy', () => {
it('should render sorted obj and returning 1 value', async () => {
it('should render sorted numbers and returning 1 value', async () => {
const element = await fixture(html`

@@ -20,9 +21,24 @@ <div>${orderBy(obj, 'a')[0].a}</div>

});
it('should render sorted obj and returning 2 value', async () => {
it('should render sorted numbers and returning 3 value', async () => {
const element = await fixture(html`
<div>${orderBy(obj, 'b')[0].a}</div>
<div>${orderBy(obj, 'a', ['desc'])[0].a}</div>
`);
expect(decode(element.innerHTML)).to.have.string(2);
expect(decode(element.innerHTML)).to.have.string(3);
});
it('should render sorted strings and returning 1 value', async () => {
const element = await fixture(html`
<div>${orderBy(strings, 'a')[0].a}</div>
`);
expect(decode(element.innerHTML)).to.have.string('a');
});
it('should render sorted strings and returning 3 value', async () => {
const element = await fixture(html`
<div>${orderBy(strings, 'a', ['desc'])[0].a}</div>
`);
expect(decode(element.innerHTML)).to.have.string('c');
});
});
import { get } from '../get/get.js';
import '../get/index.js';
import { langsConfig } from './translate.langs.js';

@@ -3,0 +4,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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