🎉 ✅ setup tests and add some
This commit is contained in:
@@ -2,6 +2,12 @@
|
||||
import * as R from 'ramda'
|
||||
|
||||
/// Types
|
||||
const Category = {
|
||||
title: String,
|
||||
slug: String,
|
||||
resources: [Resource],
|
||||
}
|
||||
|
||||
const Resource = {
|
||||
title: String,
|
||||
cleanTitle: String,
|
||||
@@ -11,12 +17,6 @@ const Resource = {
|
||||
tags: [String],
|
||||
}
|
||||
|
||||
const Category = {
|
||||
title: String,
|
||||
slug: String,
|
||||
resources: [Resource],
|
||||
}
|
||||
|
||||
/// Functions
|
||||
// isNotEmpty [a] -> Bool
|
||||
export const isNotEmpty = R.compose(R.not, R.isEmpty)
|
||||
@@ -39,17 +39,10 @@ export const tagsNotEmpty = R.compose(isNotEmpty, R.prop('tags'))
|
||||
export const cleanString = R.compose(R.toLower, R.trim)
|
||||
|
||||
// true if list2 has element that appears in list1 else false
|
||||
// includesElOf([1, 2])([2]) -> true
|
||||
// includesElOf([1, 2], [3]) -> false
|
||||
// includesElOf(['a', 'b'], ['a']) -> true
|
||||
// includesElOf(['aa', 'b'], ['a']) -> false
|
||||
// includesElOf :: [a] -> [a] -> Bool
|
||||
export const includesElOf = R.curry((list1, list2) => R.any(el => R.includes(el, list2), list1))
|
||||
|
||||
// Similar to includesElOf, but partially included strings are also allowed
|
||||
// partiallyIncludesElOf(['a', 'b'])(['a']) -> true
|
||||
// partiallyIncludesElOf(['aa', 'b'], ['a']) -> true
|
||||
// partiallyIncludesElOf(['aa', 'b'], ['c']) -> false
|
||||
// partiallyIncludesElOf :: [String] -> [String] -> Bool
|
||||
export const partiallyIncludesElOf = R.curry((list1, list2) =>
|
||||
R.any(el2 =>
|
||||
|
||||
Reference in New Issue
Block a user