<commit_before>import Ember from 'ember';
import hbs from 'htmlbars-inline-precompile';

const { computed } = Ember;

export default Ember.Component.extend({
  layout: hbs`{{actionText}}`,
  tagName: 'a',
  role: 'button',
  attributeBindings: ['role', 'download', 'href'],
  download: computed('filename', 'extension', function() {
    return `${this.get('filename')}-${new Date().toISOString()}.${this.get('extension')}`;
  }),

  href: computed('data', 'mime', 'stringify', function() {
    let data = this.get('data');
    const mime = this.get('mime');
    if (this.get('stringify')) {
      data = JSON.stringify(data, null, 2);
    }

    const file = new File([data], { type: mime });
    return window.URL.createObjectURL(file);
  }),<commit_msg>use ms-specific api for saving Blobs instead of using the File constructor (#4376)<commit_after>import Ember from 'ember';
import hbs from 'htmlbars-inline-precompile';

const { computed } = Ember;

export default Ember.Component.extend({
  layout: hbs`{{actionText}}`,
  tagName: 'a',
  role: 'button',
  attributeBindings: ['role', 'download', 'href'],
  download: computed('filename', 'extension', function() {
    return `${this.get('filename')}-${new Date().toISOString()}.${this.get('extension')}`;
  }),

  fileLike: computed('data', 'mime', 'strigify', 'download', function() {
    let file;
    let data = this.get('data');
    let filename = this.get('download');
    let mime = this.get('mime');
    if (this.get('stringify')) {
      data = JSON.stringify(data, null, 2);
    }
    if (window.navigator.msSaveOrOpenBlob) {
      file = new Blob([data], { type: mime });
      file.name = filename;
    } else {
      file = new File([data], filename, { type: mime });
    }
    return file;
  }),

  href: computed('fileLike', function() {
    return window.URL.createObjectURL(this.get('fileLike'));
  }),

  click(event) {
    if (!window.navigator.msSaveOrOpenBlob) {
      return;
    }
    event.preventDefault();
    let file = this.get('fileLike');
    //lol whyyyy
    window.navigator.msSaveOrOpenBlob(file, file.name);
  },
{'fraction_non_alphanumeric': 0.18619047619047618, 'fraction_numerical': 0.002857142857142857, 'mean_word_length': 3.863425925925926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4024805', 'n_tokens_mistral': 683, 'n_tokens_neox': 674, 'n_words': 157}