Skip to content

Instantly share code, notes, and snippets.

View ArtemRomanovsky's full-sized avatar

ArtemRomanovsky

View GitHub Profile
const dataProduces = {{state.produces}};
const dataSnacks = {{state.snacks}};
const dataMeat = {{state.meat}};
const searchedData = {{data}};
if (!searchedData) {
return {produces:dataProduces, snacks:dataSnacks,meat:dataMeat};
}
function filter(item, value) {
return item.weight.toLowerCase().includes(value) || item.price.toLowerCase().includes(value) || item.product.toLowerCase().includes(value);
}
return {{state.opportunities}}.filter(item => {
return ['Closed—lost', 'Closed—won'].includes(item.fields['Status']);
}).length;
const allData = [...{{state.allData}}];
const page = {{state.offSet}};
const limit = {{state.limit}};
return allData.slice(page * limit, page * limit + limit);
const direction = {{data}};
return Math.max(0, {{state.offSet}} + direction);
function indexEqualsValue(a) {
let left = 0;
let right = a.length - 1;
let mid;
while (left != right) {
mid = Math.floor(((right - left) / 2) + left);
if (mid <= a[mid]) {
right = mid;
} else {