Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return targets
.filter(target => !mdnSupported(node, target))
.map(formatTargetNames);
}
function getMetadataName(metadata: Node) {
switch (metadata.protoChain.length) {
case 1: {
return metadata.protoChain[0];
}
default:
return `${metadata.protoChain.join('.')}()`;
}
}
const MdnProvider: Array = AstMetadata
// Create entries for each ast node type
.map(metadata =>
metadata.astNodeTypes.map(astNodeType => ({
...metadata,
name: getMetadataName(metadata),
id: metadata.protoChainId,
protoChainId: metadata.protoChainId,
astNodeType,
object: metadata.protoChain[0],
// @TODO Handle cases where 'prototype' is in protoChain
property: metadata.protoChain[1]
}))
)
// Flatten the array of arrays
.reduce((p, c) => [...p, ...c])
// Add rule and target support logic for each entry
protoChainId: string,
astNodeTypes: Array,
isStatic: boolean,
compat: {
support: {
[browserName: string]: {
// If a version is true then it is supported but version is unsure
version_added: string | boolean
}
},
[x: string]: any
}
};
const mdnRecords: Map = new Map(
AstMetadata.map(e => [e.protoChainId, e])
);
/**
* Map ids of mdn targets to their "common/friendly" name
*/
const targetNameMappings = {
chrome: 'Chrome',
firefox: 'Firefox',
opera: 'Opera',
safari: 'Safari',
ie: 'IE',
edge: 'Edge',
safari_ios: 'iOS Safari',
opera_android: 'Opera Mobile',
chrome_android: 'Android Chrome',
edge_mobile: 'Edge Mobile',