|
const NEW_VERSION = '11.0.0'; |
|
const PREVIOUS_VERSION = '10.0.0'; |
|
|
|
const { |
|
propertiesToAliases, |
|
valuesToAliasesPerProperty |
|
} = require('./aliases.js'); |
|
|
|
const formatter = new Intl.NumberFormat(); |
|
const formatNumber = (number) => formatter.format(number); |
|
|
|
console.log(`Comparing Unicode v${ NEW_VERSION } to Unicode v${ PREVIOUS_VERSION }…`); |
|
|
|
const diffProperties = (name) => { |
|
const a = require(`unicode-${ PREVIOUS_VERSION }`)[name]; |
|
const b = new Set(require(`unicode-${ NEW_VERSION }`)[name]); |
|
const diff = new Set(a.filter(x => !b.has(x))); |
|
if (diff.size) { |
|
console.log(diff); |
|
console.log(`Note: didn’t check for new ${ name } values`); // TODO |
|
} else { |
|
const delta = b.size - a.length; |
|
console.log(`${ name }: ${ formatNumber(delta) } new values`); |
|
if (delta) { |
|
const props = [...b].filter(x => !a.includes(x)); |
|
for (const prop of props) { |
|
const aliases = name === 'Binary_Property' |
|
? propertiesToAliases.get(prop) |
|
: valuesToAliasesPerProperty.get(name).get(prop); |
|
const aliasText = aliases ? ` (${ aliases.join(', ') })` : ''; |
|
console.log(`- ${ prop }${ aliasText }`); |
|
} |
|
} |
|
} |
|
}; |
|
|
|
diffProperties('Binary_Property'); |
|
diffProperties('General_Category'); |
|
diffProperties('Script'); |
|
diffProperties('Script_Extensions'); |
|
|
|
const properties = [ |
|
'Binary_Property/ID_Start', |
|
'Binary_Property/ID_Continue', |
|
'General_Category/Space_Separator', |
|
]; |
|
for (const property of properties) { |
|
const a = require(`unicode-${ PREVIOUS_VERSION }/${ property }/code-points.js`); |
|
const b = new Set(require(`unicode-${ NEW_VERSION }/${ property }/code-points.js`)); |
|
const diff = new Set(a.filter(x => !b.has(x))); |
|
console.log(`${ property }: ${ formatNumber(diff.size) } removals`); |
|
if (diff.size) { |
|
console.log(diff); |
|
console.log('Note: didn’t check for new code points'); // TODO |
|
} else { |
|
const delta = b.size - a.length; |
|
console.log(`${ property }: ${ formatNumber(delta) } new code points`); |
|
} |
|
} |
|
|
|
const caseFoldings = ['S', 'F']; |
|
for (const form of caseFoldings) { |
|
const a = Object.keys(require(`unicode-${ PREVIOUS_VERSION }/Case_Folding/${ form }/code-points.js`)); |
|
const b = new Set(Object.keys(require(`unicode-${ NEW_VERSION }/Case_Folding/${ form }/code-points.js`))); |
|
const removals = new Set(a.filter(x => !b.has(x))); |
|
console.log(`Case_Folding=${ form }: ${ formatNumber(removals.size) } removals`); |
|
if (removals.size) { |
|
console.log(removals); |
|
console.log('Note: didn’t check for new code points'); // TODO |
|
} else { |
|
const delta = b.size - a.length; |
|
console.log(`Case_Folding=${ form }: ${ formatNumber(delta) } new code points`); |
|
} |
|
} |