Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (selectorText.indexOf(',') > -1) {
selectorText.split(/\s*,\s*/).forEach(st => {
buildSelectorTextToCSSText(selectorTextToCSSTexts, st, cssText);
});
} else {
buildSelectorTextToCSSText(
selectorTextToCSSTexts,
selectorText,
cssText
);
}
});
});
// Sort selector by
stable(selectorTextToCSSTexts, sortBySpecificity)
.reduce(buildElementToCSSTexts.bind(null, doc), new Map())
.forEach(applyInlineStyleSheetCSSTexts);
}
result.seenIps[ip] = true
result.unique.push(cleanedService)
return result
},
{ unique: [], seenIps: {} }
).unique
const dedupedWithoutIp = differenceBy(
uniqBy(listWithoutIp, 'name'),
sanitizedWithIp,
'name'
)
// use a stable sort because core-js polyfills can mess with Array.sort order
return stableSort(sanitizedWithIp.concat(dedupedWithoutIp), compareServices)
}
export default function reduce(state = defaultState, action) {
let { byId, list, listIndex, view, viewIndex } = state
switch (action.type) {
case SET_FILTER:
view = stable(list.filter(action.filter), action.sort)
viewIndex = {}
view.forEach((item, index) => {
viewIndex[item.id] = index
})
break
case SET_SORT:
view = stable([...view], action.sort)
viewIndex = {}
view.forEach((item, index) => {
viewIndex[item.id] = index
})
break
case ADD:
if (action.item.id in byId) {
// we already had that.
break
}
byId = { ...byId, [action.item.id]: action.item }
listIndex = { ...listIndex, [action.item.id]: list.length }
list = [...list, action.item]
if (action.filter(action.item)) {
({ view, viewIndex } = sortedInsert(state, action.item, action.sort))
const dataToSort = data.map((rowData, index) => ({
rowData,
index,
sortValue: getSortValue(column, rowData, index, data, columns),
}));
// check if already sorted, and if so, just reverse
let sortedData;
// if already sorted in the opposite order, just reverse it
if (alreadySorted(!sortDirection, dataToSort, comparator)) {
sortedData = dataToSort.reverse();
// if not sorted, stable sort it
} else {
sortedData = stable(dataToSort, comparator);
if (sortDirection === SortDirection.Descending) {
sortedData.reverse();
}
}
sortedData = sortedData.map(sortItem => sortItem.rowData);
return sortedData;
}
export default function reduce(state = defaultState, action) {
let { byId, list, listIndex, view, viewIndex } = state
switch (action.type) {
case SET_FILTER:
view = stable(list.filter(action.filter), action.sort)
viewIndex = {}
view.forEach((item, index) => {
viewIndex[item.id] = index
})
break
case SET_SORT:
view = stable([...view], action.sort)
viewIndex = {}
view.forEach((item, index) => {
viewIndex[item.id] = index
})
break
case ADD:
if (action.item.id in byId) {
return function sort(inPlace, iterable, selector, comparator = defaultComparator) {
let array = ensureArray(iterable);
const wrappedComparator = selector
? (a, b) => comparator(selector(itemValue(a)), selector(itemValue(b)))
: (a, b) => comparator(itemValue(a), itemValue(b));
if (inPlace) {
stable.inplace(array, wrappedComparator);
} else {
array = stable(array, wrappedComparator);
}
if (collectionType === 'Sequence' || collectionSubtype === 'Indexed') {
return array;
}
return new NativeConstructor(array);
};
}
const frontMatter = fm(contents);
const attributes = frontMatter.attributes;
const body = frontMatter.body;
const slug = file.replace('.md', '');
attributes.body = body;
attributes.url = `${baseUrl}/blog/${slug}/`;
attributes.fullImage = `${baseUrl}${attributes.image}`;
attributes.slug = slug;
attributes.created = new Date(attributes.created);
attributes.readTime = utils.readTime(body);
return { file: filePath, attributes };
});
const sortedFiles: IFileObject[] = sort(
_(newFiles)
.filter(_.isObject)
.value(),
(a: IFileObject, b: IFileObject) => {
return a.attributes.created <= b.attributes.created;
}
);
const filteredFiles = _(sortedFiles)
.filter((file) => {
return file.attributes.published !== false;
})
.value();
if (config.ENV.prod) {
cache.store('blog-files', blogFiles);