Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
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.

index.js 505B

123456789101112131415161718192021
  1. 'use strict';
  2. const detectNewline = string => {
  3. if (typeof string !== 'string') {
  4. throw new TypeError('Expected a string');
  5. }
  6. const newlines = string.match(/(?:\r?\n)/g) || [];
  7. if (newlines.length === 0) {
  8. return;
  9. }
  10. const crlf = newlines.filter(newline => newline === '\r\n').length;
  11. const lf = newlines.length - crlf;
  12. return crlf > lf ? '\r\n' : '\n';
  13. };
  14. module.exports = detectNewline;
  15. module.exports.graceful = string => (typeof string === 'string' && detectNewline(string)) || '\n';