@forter/directives
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -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 @@ |
@@ -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 |
{ | ||
"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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
49807
3
65
590
0
- Removedlodash-es@^4.17.11
- Removedlodash-es@4.17.21(transitive)