Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

generate-code-points.js 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. 'use strict';
  2. const bitfield = require('sparse-bitfield');
  3. const codePoints = require('./lib/code-points');
  4. const unassigned_code_points = bitfield();
  5. const commonly_mapped_to_nothing = bitfield();
  6. const non_ascii_space_characters = bitfield();
  7. const prohibited_characters = bitfield();
  8. const bidirectional_r_al = bitfield();
  9. const bidirectional_l = bitfield();
  10. /**
  11. * @param {bitfield} bits
  12. * @param {array} src
  13. */
  14. function traverse(bits, src) {
  15. for(const code of src.keys()) {
  16. bits.set(code, true);
  17. }
  18. const buffer = bits.toBuffer();
  19. return Buffer.concat([ createSize(buffer), buffer ]);
  20. }
  21. /**
  22. * @param {Buffer} buffer
  23. * @returns {Buffer}
  24. */
  25. function createSize(buffer) {
  26. const buf = Buffer.alloc(4);
  27. buf.writeUInt32BE(buffer.length);
  28. return buf;
  29. }
  30. const memory = [];
  31. memory.push(
  32. traverse(unassigned_code_points, codePoints.unassigned_code_points),
  33. traverse(commonly_mapped_to_nothing, codePoints.commonly_mapped_to_nothing),
  34. traverse(non_ascii_space_characters, codePoints.non_ASCII_space_characters),
  35. traverse(prohibited_characters, codePoints.prohibited_characters),
  36. traverse(bidirectional_r_al, codePoints.bidirectional_r_al),
  37. traverse(bidirectional_l, codePoints.bidirectional_l),
  38. );
  39. process.stdout.write(Buffer.concat(memory));