<commit_before>// Rules which have been enforced in configuration upgrades and flag issues in existing code.
// We need to consider whether to disable those rules permanently, or fix the issues.
const legacyCode = {
  'class-methods-use-this': 'off',
  'constructor-super': 'off',
  'default-param-last': 'off',
  'max-classes-per-file': 'off',
  'no-await-in-loop': 'off',
  'no-continue': 'off',
  'no-else-return': 'off',
  'no-plusplus': 'off',
  'no-prototype-builtins': 'off',
  'no-restricted-syntax': 'off',
  'no-this-before-super': 'off',
  'prefer-destructuring': 'off',
  'prefer-promise-reject-errors': 'off',
};

module.exports = {
  extends: [
    '@wagtail/eslint-config-wagtail',
    'plugin:@typescript-eslint/recommended',
  ],
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint'],
  env: {
    jest: true,
    browser: true,
  },
  rules: {
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-member-accessibility': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-use-before-define': ['error'],
    'import/extensions': [
      'error',
      'always',
      {
        ignorePackages: true,
        pattern: {
          js: 'never',
          jsx: 'never',
          ts: 'never',
          tsx: 'never',
        },
      },
    ],
    // does not align with the majority of legacy and newer code, some use named others use default exports
    'import/prefer-default-export': 'off',
    // allow no lines between single line members (e.g. static declarations)
    'lines-between-class-members': [
      'error',
      'always',
      { exceptAfterSingleLine: true },
    ],
    // note you must disable the base rule as it can report incorrect errors
    'no-use-before-define': 'off',
    'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
    'no-underscore-dangle': [
      'error',
      { allow: ['__REDUX_DEVTOOLS_EXTENSION__'] },
    ],
  },
  settings: {
    'import/core-modules': ['jquery'],
    'import/resolver': { node: { extensions: ['.js', '.ts', '.tsx'] } },
  },
  overrides: [
    // Legacy Code - remove from `files` when adopting desired rules in new code progressively
    {
      files: [
        'client/src/entrypoints/**',
        'client/src/utils/**',
        '**/documents/static_src/wagtaildocs/js/add-multiple.js',
        '**/images/static_src/wagtailimages/js/add-multiple.js',
        '**/images/static_src/wagtailimages/js/focal-point-chooser.js',
        '**/snippets/static_src/wagtailsnippets/js/snippet-multiple-select.js',
      ],
      rules: legacyCode,
    },
    // Rules that we are ignoring currently due to legacy code in React components only
    {
      files: ['client/src/components/**'],
      rules: {
        ...legacyCode,
        'jsx-a11y/click-events-have-key-events': 'off',
        'jsx-a11y/interactive-supports-focus': 'off',
        'jsx-a11y/no-noninteractive-element-interactions': 'off',
        'jsx-a11y/role-supports-aria-props': 'off',
        'react-hooks/exhaustive-deps': 'off',
        'react-hooks/rules-of-hooks': 'off',
        'react/button-has-type': 'off',
        'react/destructuring-assignment': 'off',
        'react/forbid-prop-types': 'off',
        'react/function-component-definition': 'off',
        'react/jsx-props-no-spreading': 'off',
        'react/no-danger': 'off',
        'react/no-deprecated': 'off',
        'react/require-default-props': 'off',
      },
    },
    // Rules we don’t want to enforce for test and tooling code.
    {
      files: [
        'client/extract-translatable-strings.js',
        'client/tests/**',
        'webpack.config.js',
        'tailwind.config.js',
        'storybook/**/*',
        '*.test.ts',
        '*.test.tsx',
        '*.test.js',
        '*.stories.js',
        '*.stories.tsx',
      ],
      rules: {
        '@typescript-eslint/no-empty-function': 'off',
        '@typescript-eslint/no-unused-vars': 'off',
        '@typescript-eslint/no-var-requires': 'off',
        'global-require': 'off',
        'import/first': 'off',
        'import/no-extraneous-dependencies': 'off',
        'no-unused-expressions': 'off',
        'react/function-component-definition': 'off',
        'react/jsx-props-no-spreading': 'off',
      },
    },
    // Files that use jquery via a global
    {
      files: [
        'docs/_static/**',
        'wagtail/contrib/modeladmin/static_src/wagtailmodeladmin/js/prepopulate.js',
        'wagtail/contrib/settings/static_src/wagtailsettings/js/site-switcher.js',
        'wagtail/documents/static_src/wagtaildocs/js/add-multiple.js',
        'wagtail/embeds/static_src/wagtailembeds/js/embed-chooser-modal.js',
        'wagtail/images/static_src/wagtailimages/js/add-multiple.js',
        'wagtail/images/static_src/wagtailimages/js/focal-point-chooser.js',
        'wagtail/images/static_src/wagtailimages/js/image-url-generator.js',
        'wagtail/search/static_src/wagtailsearch/js/query-chooser-modal.js',
        'wagtail/search/templates/wagtailsearch/queries/chooser_field.js',
        'wagtail/snippets/static_src/wagtailsnippets/js/snippet-multiple-select.js',
        'wagtail/users/static_src/wagtailusers/js/group-form.js',
      ],
      globals: { $: 'readonly', jQuery: 'readonly' },
    },
    // Files that use other globals or legacy/vendor code that is unable to be easily linted
    {
      files: ['wagtail/**/**'],
      globals: {
        addMessage: 'readonly',
        buildExpandingFormset: 'readonly',
        cancelSpinner: 'readonly',
        escapeHtml: 'readonly',
        jsonData: 'readonly',
        ModalWorkflow: 'readonly',
        DOCUMENT_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
        EMBED_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
        IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
        QUERY_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
        SNIPPET_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
      },
      rules: {
        '@typescript-eslint/no-unused-vars': 'off',
        '@typescript-eslint/no-use-before-define': 'off',
        'camelcase': [
          'error',
          {
            allow: [
              '__unused_webpack_module',
              '__webpack_modules__',
              '__webpack_require__',
            ],
            properties: 'never',
          },
        ],
        'consistent-return': 'off',
        'func-names': 'off',
        'id-length': 'off',
        'indent': 'off',
        'key-spacing': 'off',
        'new-cap': 'off',
        'newline-per-chained-call': 'off',
        'no-param-reassign': 'off',
        'no-underscore-dangle': 'off',
        'object-shorthand': 'off',
        'prefer-arrow-callback': 'off',
        'quote-props': 'off',
        'space-before-function-paren': 'off',
        'vars-on-top': 'off',
      },
    },
  ],
};
<commit_msg>eslint config - remove rules no longer needed<commit_after>// Rules which have been enforced in configuration upgrades and flag issues in existing code.
// We need to consider whether to disable those rules permanently, or fix the issues.
const legacyCode = {
  'class-methods-use-this': 'off',
  'constructor-super': 'off',
  'default-param-last': 'off',
  'max-classes-per-file': 'off',
  'no-continue': 'off',
  'no-else-return': 'off',
  'no-plusplus': 'off',
  'no-prototype-builtins': 'off',
  'no-restricted-syntax': 'off',
  'no-this-before-super': 'off',
  'prefer-destructuring': 'off',
};

module.exports = {
  extends: [
    '@wagtail/eslint-config-wagtail',
    'plugin:@typescript-eslint/recommended',
  ],
  parser: '@typescript-eslint/parser',
  plugins: ['@typescript-eslint'],
  env: {
    jest: true,
    browser: true,
  },
  rules: {
    '@typescript-eslint/explicit-function-return-type': 'off',
    '@typescript-eslint/explicit-member-accessibility': 'off',
    '@typescript-eslint/explicit-module-boundary-types': 'off',
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/no-use-before-define': ['error'],
    'import/extensions': [
      'error',
      'always',
      {
        ignorePackages: true,
        pattern: {
          js: 'never',
          jsx: 'never',
          ts: 'never',
          tsx: 'never',
        },
      },
    ],
    // does not align with the majority of legacy and newer code, some use named others use default exports
    'import/prefer-default-export': 'off',
    // allow no lines between single line members (e.g. static declarations)
    'lines-between-class-members': [
      'error',
      'always',
      { exceptAfterSingleLine: true },
    ],
    // note you must disable the base rule as it can report incorrect errors
    'no-use-before-define': 'off',
    'react/jsx-filename-extension': ['error', { extensions: ['.js', '.tsx'] }],
    'no-underscore-dangle': [
      'error',
      { allow: ['__REDUX_DEVTOOLS_EXTENSION__'] },
    ],
  },
  settings: {
    'import/core-modules': ['jquery'],
    'import/resolver': { node: { extensions: ['.js', '.ts', '.tsx'] } },
  },
  overrides: [
    // Legacy Code - remove from `files` when adopting desired rules in new code progressively
    {
      files: [
        'client/src/entrypoints/**',
        'client/src/utils/**',
        '**/documents/static_src/wagtaildocs/js/add-multiple.js',
        '**/images/static_src/wagtailimages/js/add-multiple.js',
        '**/images/static_src/wagtailimages/js/focal-point-chooser.js',
        '**/snippets/static_src/wagtailsnippets/js/snippet-multiple-select.js',
      ],
      rules: legacyCode,
    },
    // Rules that we are ignoring currently due to legacy code in React components only
    {
      files: ['client/src/components/**'],
      rules: {
        ...legacyCode,
        'jsx-a11y/click-events-have-key-events': 'off',
        'jsx-a11y/interactive-supports-focus': 'off',
        'jsx-a11y/no-noninteractive-element-interactions': 'off',
        'jsx-a11y/role-supports-aria-props': 'off',
        'react-hooks/exhaustive-deps': 'off',
        'react-hooks/rules-of-hooks': 'off',
        'react/button-has-type': 'off',
        'react/destructuring-assignment': 'off',
        'react/forbid-prop-types': 'off',
        'react/function-component-definition': 'off',
        'react/jsx-props-no-spreading': 'off',
        'react/no-danger': 'off',
        'react/no-deprecated': 'off',
        'react/require-default-props': 'off',
      },
    },
    // Rules we don’t want to enforce for test and tooling code.
    {
      files: [
        'client/extract-translatable-strings.js',
        'client/tests/**',
        'webpack.config.js',
        'tailwind.config.js',
        'storybook/**/*',
        '*.test.ts',
        '*.test.tsx',
        '*.test.js',
        '*.stories.js',
        '*.stories.tsx',
      ],
      rules: {
        '@typescript-eslint/no-empty-function': 'off',
        '@typescript-eslint/no-unused-vars': 'off',
        '@typescript-eslint/no-var-requires': 'off',
        'global-require': 'off',
        'import/first': 'off',
        'import/no-extraneous-dependencies': 'off',
        'no-unused-expressions': 'off',
        'react/function-component-definition': 'off',
        'react/jsx-props-no-spreading': 'off',
      },
    },
    // Files that use jquery via a global
    {
      files: [
        'docs/_static/**',
        'wagtail/contrib/modeladmin/static_src/wagtailmodeladmin/js/prepopulate.js',
        'wagtail/contrib/settings/static_src/wagtailsettings/js/site-switcher.js',
        'wagtail/documents/static_src/wagtaildocs/js/add-multiple.js',
        'wagtail/embeds/static_src/wagtailembeds/js/embed-chooser-modal.js',
        'wagtail/images/static_src/wagtailimages/js/add-multiple.js',
        'wagtail/images/static_src/wagtailimages/js/focal-point-chooser.js',
        'wagtail/images/static_src/wagtailimages/js/image-url-generator.js',
        'wagtail/search/static_src/wagtailsearch/js/query-chooser-modal.js',
        'wagtail/search/templates/wagtailsearch/queries/chooser_field.js',
        'wagtail/snippets/static_src/wagtailsnippets/js/snippet-multiple-select.js',
        'wagtail/users/static_src/wagtailusers/js/group-form.js',
      ],
      globals: { $: 'readonly', jQuery: 'readonly' },
    },
    // Files that use other globals or legacy/vendor code that is unable to be easily linted
    {
      files: ['wagtail/**/**'],
      globals: {
        addMessage: 'readonly',
        buildExpandingFormset: 'readonly',
        cancelSpinner: 'readonly',
        escapeHtml: 'readonly',
        jsonData: 'readonly',
        ModalWorkflow: 'readonly',
        DOCUMENT_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
        EMBED_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
        IMAGE_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
        QUERY_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
        SNIPPET_CHOOSER_MODAL_ONLOAD_HANDLERS: 'writable',
      },
      rules: {
        '@typescript-eslint/no-unused-vars': 'off',
        '@typescript-eslint/no-use-before-define': 'off',
        'camelcase': [
          'error',
          {
            allow: [
              '__unused_webpack_module',
              '__webpack_modules__',
              '__webpack_require__',
            ],
            properties: 'never',
          },
        ],
        'consistent-return': 'off',
        'func-names': 'off',
        'id-length': 'off',
        'indent': 'off',
        'key-spacing': 'off',
        'new-cap': 'off',
        'newline-per-chained-call': 'off',
        'no-param-reassign': 'off',
        'no-underscore-dangle': 'off',
        'object-shorthand': 'off',
        'prefer-arrow-callback': 'off',
        'quote-props': 'off',
        'space-before-function-paren': 'off',
        'vars-on-top': 'off',
      },
    },
  ],
};
<|endoftext|>


<commit_before>function removeWhitespace(string) {
    return string.replace(/\s+/g, '');
}

describe('scrambler tests', function(){
    beforeEach(function() {
        fixture.setBase('fixtures')
    });

    beforeEach(function(){
        this.sample = fixture.load('sample.html');
    });

    afterEach(function() {
        fixture.cleanup();
    });

    it('plays with the html fixture', function() {
        jasmine.clock().install();

        var runSpy = spyOn(scrambler._scrambler, "run").and.callThrough();
        var originalContent = removeWhitespace(this.sample[0].textContent);

        scrambler.scramble(this.sample[0], false);
        expect(runSpy.calls.count()).toEqual(1);

        jasmine.clock().tick(501);
        expect(runSpy.calls.count()).toEqual(3);

        expect(originalContent).not.toEqual(removeWhitespace(this.sample[0].textContent))

        jasmine.clock().uninstall();
    });

    it('defaults on body when calling the go function', function() {
        var scramblerSpy = spyOn(scrambler, "scramble");

        scrambler.go('en');

        expect(scramblerSpy.calls.count()).toEqual(1);
        expect(scramblerSpy).toHaveBeenCalledWith(document.querySelector('body'), true);
    });

    it('the go function accepts a custom element', function() {
        var scramblerSpy = spyOn(scrambler, "scramble");

        scrambler.go('en', this.sample[0]);

        expect(scramblerSpy.calls.count()).toEqual(1);
        expect(scramblerSpy).toHaveBeenCalledWith(this.sample[0], true);
    });

    it('stops the scrambling', function() {
        scrambler.scramble(this.sample[0], false);

        expect(scrambler._scrambler.running).toEqual(true);

        scrambler.stop();

        expect(scrambler._scrambler.running).toEqual(false);
    });

    it('restores the original content', function() {
        var originalContent = removeWhitespace(this.sample[0].textContent);

        jasmine.clock().install();

        scrambler.scramble(this.sample[0], false);

        jasmine.clock().tick(501);

        expect(originalContent).not.toEqual(removeWhitespace(this.sample[0].textContent))

        scrambler.restore();

        expect(originalContent).toEqual(removeWhitespace(this.sample[0].textContent))
        jasmine.clock().uninstall();
    });
});
<commit_msg>Check innerHTML and not text content<commit_after>function removeWhitespace(string) {
    return string.replace(/\s+/g, '');
}

describe('scrambler tests', function(){
    beforeEach(function() {
        fixture.setBase('fixtures')
    });

    beforeEach(function(){
        this.sample = fixture.load('sample.html');
    });

    afterEach(function() {
        fixture.cleanup();
    });

    it('plays with the html fixture', function() {
        jasmine.clock().install();

        var runSpy = spyOn(scrambler._scrambler, "run").and.callThrough();
        var originalContent = removeWhitespace(this.sample[0].textContent);

        scrambler.scramble(this.sample[0], false);
        expect(runSpy.calls.count()).toEqual(1);

        jasmine.clock().tick(501);
        expect(runSpy.calls.count()).toEqual(3);

        expect(originalContent).not.toEqual(removeWhitespace(this.sample[0].textContent))

        jasmine.clock().uninstall();
    });

    it('defaults on body when calling the go function', function() {
        var scramblerSpy = spyOn(scrambler, "scramble");

        scrambler.go('en');

        expect(scramblerSpy.calls.count()).toEqual(1);
        expect(scramblerSpy).toHaveBeenCalledWith(document.querySelector('body'), true);
    });

    it('the go function accepts a custom element', function() {
        var scramblerSpy = spyOn(scrambler, "scramble");

        scrambler.go('en', this.sample[0]);

        expect(scramblerSpy.calls.count()).toEqual(1);
        expect(scramblerSpy).toHaveBeenCalledWith(this.sample[0], true);
    });

    it('stops the scrambling', function() {
        scrambler.scramble(this.sample[0], false);

        expect(scrambler._scrambler.running).toEqual(true);

        scrambler.stop();

        expect(scrambler._scrambler.running).toEqual(false);
    });

    it('restores the original content', function() {
        var originalContent = this.sample[0].innerHTML;

        jasmine.clock().install();

        scrambler.scramble(this.sample[0], false);

        jasmine.clock().tick(501);

        expect(originalContent).not.toEqual(this.sample[0].innerHTML);

        scrambler.restore();

        expect(originalContent).toEqual(this.sample[0].innerHTML);

        jasmine.clock().uninstall();
    });
});
<|endoftext|>


<commit_before>import React from 'react';

import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import SpellLink from 'common/SpellLink';
import { formatPercentage } from 'common/format';

import Analyzer from 'parser/core/Analyzer';
import Enemies from 'parser/shared/modules/Enemies';
import Combatants from 'parser/shared/modules/Combatants';
import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';

class FesteringStrike extends Analyzer {
  static dependencies = {
    enemies: Enemies,
    combantants: Combatants,
  };

  // used to track how many stacks a target has
  targets = {};

  totalFesteringStrikeCasts = 0;
  festeringStrikeCastsOverFourStacks = 0;

  on_byPlayer_applydebuffstack(event){
    // we only need to look at events applying stacks after the first one, our analysis only cares about times when stacks are >4
    const spellId = event.ability.guid;
    if(spellId === SPELLS.FESTERING_WOUND.id){
      this.targets[event.targetID] = event.stack;
    }
  }

  on_byPlayer_removedebuffstack(event){
    const spellId = event.ability.guid;
    if(spellId === SPELLS.FESTERING_WOUND.id){
      this.targets[event.targetID] = event.stack;
    }
  }

  on_byPlayer_removedebuff(event){
    // keeps track of when the debuff drops off, useful for multitarget targets like DI
    const spellId = event.ability.guid;
    if(spellId === SPELLS.FESTERING_WOUND.id){
      this.targets[event.targetID] = 0;
    }
  }

  on_byPlayer_cast(event){
    const spellId = event.ability.guid;
    if(spellId === SPELLS.FESTERING_STRIKE.id){
      this.totalFesteringStrikeCasts++;
      if(this.targets.hasOwnProperty(event.targetID)){
        const currentTargetWounds = this.targets[event.targetID];
        if(currentTargetWounds > 4){
          this.festeringStrikeCastsOverFourStacks++;
        }
      }
    }
  }

  suggestions(when) {
    const percentCastsOverFourStacks = this.festeringStrikeCastsOverFourStacks/this.totalFesteringStrikeCasts;
    const strikeEfficiency = 1 - percentCastsOverFourStacks;
    when(strikeEfficiency).isLessThan(0.60)
        .addSuggestion((suggest, actual, recommended) => {
          return suggest(You are casting <SpellLink id={SPELLS.FESTERING_STRIKE.id} /> too often.  When spending runes remember to cast <SpellLink id={SPELLS.SCOURGE_STRIKE.id} /> instead on targets with more than four stacks of <SpellLink id={SPELLS.FESTERING_WOUND.id} />)
            .icon(SPELLS.FESTERING_STRIKE.icon)
            .actual(`${formatPercentage(actual)}% of Festering Strikes did not risk overcapping Festering Wounds`)
            .recommended(`>${formatPercentage(recommended)}% is recommended`)
            .regular(recommended - 0.30).major(recommended - 0.40);
        });
  }

  statistic() {
    const percentCastsOverFourStacks = this.festeringStrikeCastsOverFourStacks/this.totalFesteringStrikeCasts;
    const strikeEfficiency = 1 - percentCastsOverFourStacks;
    return (
      <StatisticBox
        icon={<SpellIcon id={SPELLS.FESTERING_STRIKE.id} />}
        value={`${formatPercentage(strikeEfficiency)} %`}
        label="Festering Strike Efficiency"
        tooltip={`${this.festeringStrikeCastsOverFourStacks} Festering Strikes were cast on a target with more than four stacks of Festering Wounds.`}
      />
    );
  }

  statisticOrder = STATISTIC_ORDER.CORE(4);
}

export default FesteringStrike;
<commit_msg>Changed festering strike efficiency to account for above 3 stacks instead<commit_after>import React from 'react';

import SPELLS from 'common/SPELLS';
import SpellIcon from 'common/SpellIcon';
import SpellLink from 'common/SpellLink';
import { formatPercentage } from 'common/format';

import Analyzer from 'parser/core/Analyzer';
import Enemies from 'parser/shared/modules/Enemies';
import Combatants from 'parser/shared/modules/Combatants';
import StatisticBox, { STATISTIC_ORDER } from 'interface/others/StatisticBox';

class FesteringStrike extends Analyzer {
  static dependencies = {
    enemies: Enemies,
    combantants: Combatants,
  };

  // used to track how many stacks a target has
  targets = {};

  totalFesteringStrikeCasts = 0;
  festeringStrikeCastsOverThreeStacks = 0;

  on_byPlayer_applydebuffstack(event){
    // we only need to look at events applying stacks after the first one, our analysis only cares about times when stacks are >3
    const spellId = event.ability.guid;
    if(spellId === SPELLS.FESTERING_WOUND.id){
      this.targets[event.targetID] = event.stack;
    }
  }

  on_byPlayer_removedebuffstack(event){
    const spellId = event.ability.guid;
    if(spellId === SPELLS.FESTERING_WOUND.id){
      this.targets[event.targetID] = event.stack;
    }
  }

  on_byPlayer_removedebuff(event){
    // keeps track of when the debuff drops off, useful for multitarget targets like DI
    const spellId = event.ability.guid;
    if(spellId === SPELLS.FESTERING_WOUND.id){
      this.targets[event.targetID] = 0;
    }
  }

  on_byPlayer_cast(event){
    const spellId = event.ability.guid;
    if(spellId === SPELLS.FESTERING_STRIKE.id){
      this.totalFesteringStrikeCasts++;
      if(this.targets.hasOwnProperty(event.targetID)){
        const currentTargetWounds = this.targets[event.targetID];
        if(currentTargetWounds > 3){
          this.festeringStrikeCastsOverThreeStacks++;
        }
      }
    }
  }

  suggestions(when) {
    const percentCastsOverThreeStacks = this.festeringStrikeCastsOverThreeStacks/this.totalFesteringStrikeCasts;
    const strikeEfficiency = 1 - percentCastsOverThreeStacks;
    when(strikeEfficiency).isLessThan(0.60)
        .addSuggestion((suggest, actual, recommended) => {
          return suggest(You are casting <SpellLink id={SPELLS.FESTERING_STRIKE.id} /> too often.  When spending runes remember to cast <SpellLink id={SPELLS.SCOURGE_STRIKE.id} /> instead on targets with more than three stacks of <SpellLink id={SPELLS.FESTERING_WOUND.id} />)
            .icon(SPELLS.FESTERING_STRIKE.icon)
            .actual(`${formatPercentage(actual)}% of Festering Strikes did not risk overcapping Festering Wounds`)
            .recommended(`>${formatPercentage(recommended)}% is recommended`)
            .regular(recommended - 0.30).major(recommended - 0.40);
        });
  }

  statistic() {
    const percentCastsOverThreeStacks = this.festeringStrikeCastsOverThreeStacks/this.totalFestFfoueringStrikeCasts;
    const strikeEfficiency = 1 - percentCastsOverThreeStacks;
    return (
      <StatisticBox
        icon={<SpellIcon id={SPELLS.FESTERING_STRIKE.id} />}
        value={`${formatPercentage(strikeEfficiency)} %`}
        label="Festering Strike Efficiency"
        tooltip={`${this.festeringStrikeCastsOverThreeStacks} Festering Strikes were cast on a target with more than three stacks of Festering Wounds.`}
      />
    );
  }

  statisticOrder = STATISTIC_ORDER.CORE(4);
}

export default FesteringStrike;
<|endoftext|>


<commit_before>(function (exports) {

  const NODE_JS = 1;
  const JS_SHELL = 2;
  const BROWSER = 3;

  var mode;
  if (typeof process !== "undefined") {
    mode = NODE_JS;
  } else if (typeof snarf !== "undefined") {
    mode = JS_SHELL;
  } else {
    mode = BROWSER;
  }

  var util, esprima, escodegen, estransform, compiler;
  var argv;

  if (mode === NODE_JS) {
    util = require("./util.js");
    esprima = require("./esprima.js");
    escodegen = require("./escodegen.js");
    estransform = require("./estransform.js");
    compiler = require("./js_compiler.js");

    snarf = require('fs').readFileSync;
    argv = process.argv.slice(2);
    print = console.log;
    quit = process.exit;
  } else if (mode === JS_SHELL) {
    load("./esprima.js");
    load("./escodegen.js");
    load("./estransform.js");
    load("./util.js");
    load("./js_compiler.js");

    argv = this.arguments;
  }

  if (mode !== NODE_JS) {
    util = this.util;
    esprima = this.esprima;
    escodegen = this.escodegen;
    estransform = this.estransform;
    compiler = this.JSCompiler;
  }

  const assert = util.assert;
  const lang = estransform.lang;
  const allFields = estransform.allFields;

  function cli() {
    var optparser = new util.OptParser([
      ["E",           "only-parse",   false, "Only parse"],
      ["A",           "emit-ast",     false, "Do not generate JS, emit AST"],
      ["P",           "pretty-print", false, "Pretty-print AST instead of emitting JSON (with -A)"],
      ["b",           "bare",         false, "Do not wrap in a module"],
      ["l",           "load-instead", false, "Emit load('memory') instead of require('memory')"],
      ["W",           "warn",         true,  "Print warnings (enabled by default)"],
      ["Wconversion",  null,          false, "Print intra-integer and pointer conversion warnings"],
      ["0",           "simple-log",   false, "Log simple messages. No colors and snippets."],
      ["t",           "trace",        false, "Trace compiler execution"],
      ["o",           "output",       "",    "Output file name"],
      ["h",           "help",         false, "Print this message"],
      ["w",           "nowarn",       false, "Inhibit all warning messages"],
      ["m",           "minify",       false, "Do rudimentary minification"],
      ["Z",           "lazy-minimum", "", "Enable lazy function parsing with minimum length (defaults to all functions if enabled)"],
      ["Zf",          "new-function", false, "Use new Function instead of eval when possible"],
      ["Zs",          "split-strings","", "Split lazy function strings into a new file (implies building for browser)"],
      ["Zc",          "call-graph",   false, "Use call graph information for lazy parsing thresholding"],
      ["Zi",          "profile-calls", false, "Add instrumentation code to profile which functions get called"],
      ["Zp",          "read-profile", "",    "Read profile information from filename"],
      ["",            "no-loc",       false, "Do not include location information in the AST (less useful debug info)"],
      ["",            "min-len",      "", "Minimum length function to touch (either to insert profiling or for deferring)"]
    ]);

    var p = optparser.parse(argv);
    if (!p) {
      quit(1);
    }

    var options = p.options;
    var files = p.rest;

    if (!files.length || options.help) {
      print("jsc: [option(s)] file");
      print(optparser.usage());
      quit();
    }

    var filename = files[0];
    var path = filename.split("/");
    var basename = path.pop();
    var dir = path.join("/");
    basename = basename.substr(0, basename.lastIndexOf(".")) || basename;

    var source = snarf(filename);
    var code = compile(basename, filename, source, options);

    if (options["pretty-print"]) {
      print(util.pretty(code));
    } else {
      // SpiderMonkey has no way to write to a file, but if we're on node we can
      // emit .js.
      if (options["output"] && mode === NODE_JS && !options["only-parse"]) {
        // var outname = (dir ? dir + "/" : "") + basename;
        // Don't overwrite the source file by mistake.
        if (options["output"] !== filename) {
          if (options["emit-ast"]) {
            require('fs').writeFileSync(options["output"], JSON.stringify(code, null, 2));
          } else {
            // Escodegen doesn't emit a final newline for some reason, so add one.
            require('fs').writeFileSync(options["output"], code + "\n");
          }
        }
      } else {
        print(code);
      }
    }
  }

  function compile(name, logName, source, options) {
    // -W anything infers -W.
    for (var p in options) {
      if (p.charAt(0) === "W") {
        options.warn = true;
        break;
      }
    }

    if(options.nowarn) {
      options.warn = false;
    }

    var logger = new util.Logger("jsc", logName, source, options);
    var code;

    try {
      // var node = esprima.parse(source, { loc: true, comment: true, range: true, tokens: true, jsInput: true });

      // node = escodegen.attachComments(node, node.comments, node.tokens);

      var node = esprima.parse(source, { loc: !options["no-loc"], jsInput: true });

      var outputFormat = {};
      if (options["minify"]) {
        outputFormat.compact = true;
      }

      if (options["only-parse"]) {
        code = node;
      } else {
        node = compiler.compile(node, name, logger, options);
        if (options["emit-ast"]) {
          code = node;
        } else {
          code = escodegen.generate(node, { base: "", indent: "  ", comment: true, format: outputFormat});
        }
      }
    } catch (e) {
      if (mode === BROWSER) {
        throw e;
      }

      if (e.index) {
        // Esprima error, make a loc out of it.
        var lc = { line: e.lineNumber, column: e.column - 1 };
        e.loc = { start: lc, end: lc };
        logger.error(e.message, { start: lc, end: lc });
        logger.flush();
        quit(1);
      }

      if (e.logged && mode !== BROWSER) {
        // Compiler error that has already been logged, so just flush and
        // quit.
        logger.flush();
        quit(1);
      }

      throw e;
    }

    logger.flush();
    return code;
  }

  exports.cli = cli;
  exports.compile = compile;

  if (mode === JS_SHELL) {
    cli();
  }

}).call(this, typeof exports === "undefined" ? (LSC = {}) : exports);
<commit_msg>Fixed no-loc and comments<commit_after>(function (exports) {

  const NODE_JS = 1;
  const JS_SHELL = 2;
  const BROWSER = 3;

  var mode;
  if (typeof process !== "undefined") {
    mode = NODE_JS;
  } else if (typeof snarf !== "undefined") {
    mode = JS_SHELL;
  } else {
    mode = BROWSER;
  }

  var util, esprima, escodegen, estransform, compiler;
  var argv;

  if (mode === NODE_JS) {
    util = require("./util.js");
    esprima = require("./esprima.js");
    escodegen = require("./escodegen.js");
    estransform = require("./estransform.js");
    compiler = require("./js_compiler.js");

    snarf = require('fs').readFileSync;
    argv = process.argv.slice(2);
    print = console.log;
    quit = process.exit;
  } else if (mode === JS_SHELL) {
    load("./esprima.js");
    load("./escodegen.js");
    load("./estransform.js");
    load("./util.js");
    load("./js_compiler.js");

    argv = this.arguments;
  }

  if (mode !== NODE_JS) {
    util = this.util;
    esprima = this.esprima;
    escodegen = this.escodegen;
    estransform = this.estransform;
    compiler = this.JSCompiler;
  }

  const assert = util.assert;
  const lang = estransform.lang;
  const allFields = estransform.allFields;

  function cli() {
    var optparser = new util.OptParser([
      ["E",           "only-parse",   false, "Only parse"],
      ["A",           "emit-ast",     false, "Do not generate JS, emit AST"],
      ["P",           "pretty-print", false, "Pretty-print AST instead of emitting JSON (with -A)"],
      ["b",           "bare",         false, "Do not wrap in a module"],
      ["l",           "load-instead", false, "Emit load('memory') instead of require('memory')"],
      ["W",           "warn",         true,  "Print warnings (enabled by default)"],
      ["Wconversion",  null,          false, "Print intra-integer and pointer conversion warnings"],
      ["0",           "simple-log",   false, "Log simple messages. No colors and snippets."],
      ["t",           "trace",        false, "Trace compiler execution"],
      ["o",           "output",       "",    "Output file name"],
      ["h",           "help",         false, "Print this message"],
      ["w",           "nowarn",       false, "Inhibit all warning messages"],
      ["m",           "minify",       false, "Do rudimentary minification"],
      ["Z",           "lazy-minimum", "", "Enable lazy function parsing with minimum length (defaults to all functions if enabled)"],
      ["Zf",          "new-function", false, "Use new Function instead of eval when possible"],
      ["Zs",          "split-strings","", "Split lazy function strings into a new file (implies building for browser)"],
      ["Zc",          "call-graph",   false, "Use call graph information for lazy parsing thresholding"],
      ["Zi",          "profile-calls", false, "Add instrumentation code to profile which functions get called"],
      ["Zp",          "read-profile", "",    "Read profile information from filename"],
      ["",            "no-loc",       false, "Do not include location information in the AST (less useful debug info)"],
      ["",            "min-len",      "", "Minimum length function to touch (either to insert profiling or for deferring)"]
    ]);

    var p = optparser.parse(argv);
    if (!p) {
      quit(1);
    }

    var options = p.options;
    var files = p.rest;

    if (!files.length || options.help) {
      print("jsc: [option(s)] file");
      print(optparser.usage());
      quit();
    }

    var filename = files[0];
    var path = filename.split("/");
    var basename = path.pop();
    var dir = path.join("/");
    basename = basename.substr(0, basename.lastIndexOf(".")) || basename;

    var source = snarf(filename);
    var code = compile(basename, filename, source, options);

    if (options["pretty-print"]) {
      print(util.pretty(code));
    } else {
      // SpiderMonkey has no way to write to a file, but if we're on node we can
      // emit .js.
      if (options["output"] && mode === NODE_JS && !options["only-parse"]) {
        // var outname = (dir ? dir + "/" : "") + basename;
        // Don't overwrite the source file by mistake.
        if (options["output"] !== filename) {
          if (options["emit-ast"]) {
            require('fs').writeFileSync(options["output"], JSON.stringify(code, null, 2));
          } else {
            // Escodegen doesn't emit a final newline for some reason, so add one.
            require('fs').writeFileSync(options["output"], code + "\n");
          }
        }
      } else {
        print(code);
      }
    }
  }

  function compile(name, logName, source, options) {
    // -W anything infers -W.
    for (var p in options) {
      if (p.charAt(0) === "W") {
        options.warn = true;
        break;
      }
    }

    if(options.nowarn) {
      options.warn = false;
    }

    var logger = new util.Logger("jsc", logName, source, options);
    var code;

    try {
      // var node = esprima.parse(source, { loc: true, comment: true, range: true, tokens: true, jsInput: true });

      var node;
      if (options["no-loc"]) {
        node = esprima.parse(source, { loc: false, jsInput: true });
      } else {
        node = esprima.parse(source, { loc: true, comment: true, range: true, tokens: true, jsInput: true });

        node = escodegen.attachComments(node, node.comments, node.tokens);
      }

      var outputFormat = {};
      if (options["minify"]) {
        outputFormat.compact = true;
      }

      if (options["only-parse"]) {
        code = node;
      } else {
        node = compiler.compile(node, name, logger, options);
        if (options["emit-ast"]) {
          code = node;
        } else {
          code = escodegen.generate(node, { base: "", indent: "  ", comment: true, format: outputFormat});
        }
      }
    } catch (e) {
      if (mode === BROWSER) {
        throw e;
      }

      if (e.index) {
        // Esprima error, make a loc out of it.
        var lc = { line: e.lineNumber, column: e.column - 1 };
        e.loc = { start: lc, end: lc };
        logger.error(e.message, { start: lc, end: lc });
        logger.flush();
        quit(1);
      }

      if (e.logged && mode !== BROWSER) {
        // Compiler error that has already been logged, so just flush and
        // quit.
        logger.flush();
        quit(1);
      }

      throw e;
    }

    logger.flush();
    return code;
  }

  exports.cli = cli;
  exports.compile = compile;

  if (mode === JS_SHELL) {
    cli();
  }

}).call(this, typeof exports === "undefined" ? (LSC = {}) : exports);
<|endoftext|>


<commit_before>/*! DataTables Bootstrap 3 integration
 * ©2011-2014 SpryMedia Ltd - datatables.net/license
 */

/**
 * DataTables integration for Bootstrap 3. This requires Bootstrap 3 and
 * DataTables 1.10 or newer.
 *
 * This file sets the defaults and adds options to DataTables to style its
 * controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
 * for further information.
 */
(function(window, document, undefined){

var factory = function( $, DataTable ) {
"use strict";

/* Set the defaults for DataTables initialisation */
$.extend( true, DataTable.defaults, {
	dom:
		"<'row'<'col-sm-6'l><'col-sm-6'f>>" +
		"<'row'<'col-sm-12'tr>>" +
		"<'row'<'col-sm-5'i><'col-sm-7'p>>",
	renderer: 'bootstrap'
} );

/* Default class modification */
$.extend( DataTable.ext.classes, {
	sWrapper:      "dataTables_wrapper form-inline dt-bootstrap",
	sFilterInput:  "form-control input-sm",
	sLengthSelect: "form-control input-sm"
} );

/* Bootstrap paging button renderer */
DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) {
	var api     = new DataTable.Api( settings );
	var classes = settings.oClasses;
	var lang    = settings.oLanguage.oPaginate;
	var btnDisplay, btnClass, counter=0;

	var attach = function( container, buttons ) {
		var i, ien, node, button;
		var clickHandler = function ( e ) {
			e.preventDefault();
			if ( !$(e.currentTarget).hasClass('disabled') ) {
				api.page( e.data.action ).draw( false );
			}
		};

		for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
			button = buttons[i];

			if ( $.isArray( button ) ) {
				attach( container, button );
			}
			else {
				btnDisplay = '';
				btnClass = '';

				switch ( button ) {
					case 'ellipsis':
						btnDisplay = '…';
						btnClass = 'disabled';
						break;

					case 'first':
						btnDisplay = lang.sFirst;
						btnClass = button + (page > 0 ?
							'' : ' disabled');
						break;

					case 'previous':
						btnDisplay = lang.sPrevious;
						btnClass = button + (page > 0 ?
							'' : ' disabled');
						break;

					case 'next':
						btnDisplay = lang.sNext;
						btnClass = button + (page < pages-1 ?
							'' : ' disabled');
						break;

					case 'last':
						btnDisplay = lang.sLast;
						btnClass = button + (page < pages-1 ?
							'' : ' disabled');
						break;

					default:
						btnDisplay = button + 1;
						btnClass = page === button ?
							'active' : '';
						break;
				}

				if ( btnDisplay ) {
					node = $('<li>', {
							'class': classes.sPageButton+' '+btnClass,
							'id': idx === 0 && typeof button === 'string' ?
								settings.sTableId +'_'+ button :
								null
						} )
						.append( $('<a>', {
								'href': '#',
								'aria-controls': settings.sTableId,
								'data-dt-idx': counter,
								'tabindex': settings.iTabIndex
							} )
							.html( btnDisplay )
						)
						.appendTo( container );

					settings.oApi._fnBindAction(
						node, {action: button}, clickHandler
					);

					counter++;
				}
			}
		}
	};

	// IE9 throws an 'unknown error' if document.activeElement is used
	// inside an iframe or frame.
	var activeEl;

	try {
		// Because this approach is destroying and recreating the paging
		// elements, focus is lost on the select button which is bad for
		// accessibility. So we want to restore focus once the draw has
		// completed
		activeEl = $(document.activeElement).data('dt-idx');
	}
	catch (e) {}

	attach(
		$(host).empty().html('<ul class="pagination"/>').children('ul'),
		buttons
	);

	if ( activeEl ) {
		$(host).find( '[data-dt-idx='+activeEl+']' ).focus();
	}
};

/*
 * TableTools Bootstrap compatibility
 * Required TableTools 2.1+
 */
if ( DataTable.TableTools ) {
	// Set the classes that TableTools uses to something suitable for Bootstrap
	$.extend( true, DataTable.TableTools.classes, {
		"container": "DTTT btn-group",
		"buttons": {
			"normal": "btn btn-default",
			"disabled": "disabled"
		},
		"collection": {
			"container": "DTTT_dropdown dropdown-menu",
			"buttons": {
				"normal": "",
				"disabled": "disabled"
			}
		},
		"print": {
			"info": "DTTT_print_info"
		},
		"select": {
			"row": "active"
		}
	} );

	// Have the collection use a bootstrap compatible drop down
	$.extend( true, DataTable.TableTools.DEFAULTS.oTags, {
		"collection": {
			"container": "ul",
			"button": "li",
			"liner": "a"
		}
	} );
}

}; // /factory

// Define as an AMD module if possible
if ( typeof define === 'function' && define.amd ) {
	define( ['jquery', 'datatables'], factory );
}
else if ( typeof exports === 'object' ) {
    // Node/CommonJS
    factory( require('jquery'), require('datatables') );
}
else if ( jQuery ) {
	// Otherwise simply initialise as normal, stopping multiple evaluation
	factory( jQuery, jQuery.fn.dataTable );
}

})(window, document);

<commit_msg>Delete dataTables.bootstrap.js<commit_after><|endoftext|>


<commit_before>/* UMD.define */ (function (root, factory) {
    if (typeof customLoader === 'function'){ customLoader(factory, 'dom'); }else if (typeof define === 'function' && define.amd) { define([], factory); } else if (typeof exports === 'object') { module.exports = factory(); } else { root.returnExports = factory(); window.dom = factory(); }
}(this, function () {
    //  convenience library for common DOM methods
    //      dom()
    //          create dom nodes
    //      dom.style()
    //          set/get node style
    //      dom.attr()
    //          set/get attributes
    //      dom.destroy()
    //          obliterates a node
    //      dom.box()
    //          get node dimensions
    //      dom.uid()
    //          get a unique ID (not dom specific)
    //
    var
        isDimension = {
            width:1,
            height:1,
            top:1,
            left:1,
            right:1,
            bottom:1,
            maxWidth:1,
            'max-width':1,
            minWidth:1,
            'min-width':1,
            maxHeight:1,
            'max-height':1
        },
        uids = {},
        destroyer = document.createElement('div');

    function uid(type){
        if(!uids[type]){
            uids[type] = [];
        }
        var id = type + '-' + (uids[type].length + 1);
        uids[type].push(id);
        return id;
    }

    function isNode(item){
        // safer test for custom elements in FF (with wc shim)
        return typeof item === 'object' && typeof item.innerHTML === 'string';
    }

    function getNode(item){

        if(!item){ return item; }
        if(typeof item === 'string'){
            return document.getElementById(item);
        }
        // de-jqueryify
        return item.get ? item.get(0) :
            // item is a dom node
            item;
    }

    function byId(id){
        return getNode(id);
    }

    function style(node, prop, value){
        // get/set node style(s)
        //      prop: string or object
        //
        var key, computed;
        if(typeof prop === 'object'){
            // object setter
            for(key in prop){
                if(prop.hasOwnProperty(key)){
                    style(node, key, prop[key]);
                }
            }
            return null;
        }else if(value !== undefined){
            // property setter
            if(typeof value === 'number' && isDimension[prop]){
                value += 'px';
            }
            node.style[prop] = value;

            if(prop === 'userSelect'){
                value = !!value ? 'text' : 'none';
                style(node, {
                    webkitTouchCallout: value,
                    webkitUserSelect: value,
                    khtmlUserSelect: value,
                    mozUserSelect: value,
                    msUserSelect: value
                });
            }
        }

        // getter, if a simple style
        if(node.style[prop]){
            if(isDimension[prop]){
                return parseInt(node.style[prop], 10);
            }
            return node.style[prop];
        }

        // getter, computed
        computed = getComputedStyle(node, prop);
        if(computed[prop]){
            if(/\d/.test(computed[prop])){
                if(!isNaN(parseInt(computed[prop], 10))){
                    return parseInt(computed[prop], 10);
                }
                return computed[prop];
            }
            return computed[prop];
        }
        return '';
    }

    function attr(node, prop, value){
        // get/set node attribute(s)
        //      prop: string or object
        //
        var key;
        if(typeof prop === 'object'){
            for(key in prop){
                if(prop.hasOwnProperty(key)){
                    attr(node, key, prop[key]);
                }
            }
            return null;
        }
        else if(value !== undefined){
            if(prop === 'text' || prop === 'html' || prop === 'innerHTML'){
                node.innerHTML = value;
            }else{
                node.setAttribute(prop, value);
            }
        }

        return node.getAttribute(prop);
    }

    function box(node){
        if(node === window){
            return {
                width: node.innerWidth,
                height: node.innerHeight
            };
        }
        // node dimensions
        // returned object is immutable
        // add scroll positioning and convenience abbreviations
        var
            dimensions = getNode(node).getBoundingClientRect(),
            box = {
                top: dimensions.top,
                right: dimensions.right,
                bottom: dimensions.bottom,
                left: dimensions.left,
                height: dimensions.height,
                h: dimensions.height,
                width: dimensions.width,
                w: dimensions.width,
                scrollY: window.scrollY,
                scrollX: window.scrollX,
                x: dimensions.left + window.pageXOffset,
                y: dimensions.top + window.pageYOffset
            };

        return box;
    }

    function query(node, selector){
        // TODO: Always return one node
        // Deprecate old way of return one or many (or null or [])
        if(!selector){
            selector = node;
            node = document;
        }
        return node.querySelector(selector);
    }

    function queryAll(node, selector){
        if(!selector){
            selector = node;
            node = document;
        }
        var nodes = node.querySelectorAll(selector);

        if(!nodes.length){ return []; }

        // convert to Array and return it
        return Array.prototype.slice.call(nodes);
    }

    function toDom(html, options, parent){
        // create a node from an HTML string
        var node = dom('div', {html: html});
        parent = byId(parent || options);
        if(parent){
            while(node.firstChild){
                parent.appendChild(node.firstChild);
            }
            return node.firstChild;
        }
        if(html.indexOf('<') !== 0){
            return node;
        }
        return node.firstChild;
    }

    function toFrag(html){
        var frag = document.createDocumentFragment();
        frag.innerHTML = html;
        return frag;
    }

    function dom(nodeType, options, parent, prepend){
        // create a node
        // if first argument is a string and starts with <, it is assumed
        // to use toDom, and creates a node from HTML. Optional second arg is
        // parent to append to
        // else:
        //      nodeType: string, type of node to create
        //      options: object with style, className, or attr properties
        //          (can also be objects)
        //      parent: Node, optional node to append to
        //      prepend: truthy, to append node as the first child
        //
        if(nodeType.indexOf('<') === 0){
            return toDom(nodeType, options, parent);
        }

        options = options || {};
        var
            className = options.css || options.className,
            node = document.createElement(nodeType);

        parent = getNode(parent);

        if(className){
            node.className = className;
        }

        if(options.html || options.innerHTML){
            node.innerHTML = options.html || options.innerHTML;
        }

        if(options.cssText){
            node.style.cssText = options.cssText;
        }

        if(options.id){
            node.id = options.id;
        }

        if(options.style){
            style(node, options.style);
        }

        if(options.attr){
            attr(node, options.attr);
        }

        if(parent && isNode(parent)){
            if(prepend && parent.hasChildNodes()){
                parent.insertBefore(node, parent.children[0]);
            }else{
                parent.appendChild(node);
            }
        }

        return node;
    }

    function destroy(node){
        // destroys a node completely
        //
        if(node) {
            destroyer.appendChild(node);
            destroyer.innerHTML = '';
        }
    }

    function clean(node, dispose){
        //	Removes all child nodes
        //		dispose: destroy child nodes
        if(dispose){
            while(node.children.length){
                destroy(node.children[0]);
            }
            return;
        }
        while(node.children.length){
            node.removeChild(node.children[0]);
        }
    }

    function ancestor (node, selector){
        // TODO: replace this with 'closest' and 'matches'
        // gets the ancestor of node based on selector criteria
        // useful for getting the target node when a child node is clicked upon
        //
        // USAGE
        //      on.selector(childNode, '.app.active');
        //      on.selector(childNode, '#thinger');
        //      on.selector(childNode, 'div');
        //	DOES NOT SUPPORT:
        //		combinations of above
        var
            test,
            parent = node;

        if(selector.indexOf('.') === 0){
            // className
            selector = selector.replace('.', ' ').trim();
            test = function(n){
                return n.classList.contains(selector);
            };
        }
        else if(selector.indexOf('#') === 0){
            // node id
            selector = selector.replace('#', '').trim();
            test = function(n){
                return n.id === selector;
            };
        }
        else if(selector.indexOf('[') > -1){
            // attribute
            console.error('attribute selectors are not yet supported');
        }
        else{
            // assuming node name
            selector = selector.toUpperCase();
            test = function(n){
                return n.nodeName === selector;
            };
        }

        while(parent){
            if(parent === document.body || parent === document){ return false; }
            if(test(parent)){ break; }
            parent = parent.parentNode;
        }

        return parent;
    }

    dom.classList = {
        remove: function(node, names){
            toArray(names).forEach(function(name){
                node.classList.remove(name);
            });
        },
        add: function(node, names){
            toArray(names).forEach(function(name){
                node.classList.add(name);
            });
        },
        contains: function(node, names){
            return toArray(names).every(function (name) {
                return node.classList.contains(name);
            });
        },
        toggle: function(node, names, value){
            toArray(names).forEach(function(name){
                node.classList.toggle(name, value);
            });
        }
    };

    function toArray(names){
        if(!names){
            console.error('dom.classList should include a node and a className');
            return [];
        }
        return names.split(' ').map(function (name) {
            return name.trim();
        });
    }

    if (!window.requestAnimationFrame) {
        dom.requestAnimationFrame = function(callback){
            setTimeout(callback, 0);
        };
    }else{
        dom.requestAnimationFrame = function(cb){
            window.requestAnimationFrame(cb);
        };
    }

    dom.clean = clean;
    dom.query = query;
    dom.queryAll = queryAll;
    dom.byId = byId;
    dom.attr = attr;
    dom.box = box;
    dom.style = style;
    dom.destroy = destroy;
    dom.uid = uid;
    dom.isNode = isNode;
    dom.ancestor = ancestor;
    dom.toDom = toDom;
    dom.toFrag = toFrag;

    return dom;
}));
<commit_msg>Fix innerHTML falsey bug<commit_after>/* UMD.define */ (function (root, factory) {
    if (typeof customLoader === 'function'){ customLoader(factory, 'dom'); }else if (typeof define === 'function' && define.amd) { define([], factory); } else if (typeof exports === 'object') { module.exports = factory(); } else { root.returnExports = factory(); window.dom = factory(); }
}(this, function () {
    //  convenience library for common DOM methods
    //      dom()
    //          create dom nodes
    //      dom.style()
    //          set/get node style
    //      dom.attr()
    //          set/get attributes
    //      dom.destroy()
    //          obliterates a node
    //      dom.box()
    //          get node dimensions
    //      dom.uid()
    //          get a unique ID (not dom specific)
    //
    var
        isDimension = {
            width:1,
            height:1,
            top:1,
            left:1,
            right:1,
            bottom:1,
            maxWidth:1,
            'max-width':1,
            minWidth:1,
            'min-width':1,
            maxHeight:1,
            'max-height':1
        },
        uids = {},
        destroyer = document.createElement('div');

    function uid(type){
        if(!uids[type]){
            uids[type] = [];
        }
        var id = type + '-' + (uids[type].length + 1);
        uids[type].push(id);
        return id;
    }

    function isNode(item){
        // safer test for custom elements in FF (with wc shim)
        return typeof item === 'object' && typeof item.innerHTML === 'string';
    }

    function getNode(item){

        if(!item){ return item; }
        if(typeof item === 'string'){
            return document.getElementById(item);
        }
        // de-jqueryify
        return item.get ? item.get(0) :
            // item is a dom node
            item;
    }

    function byId(id){
        return getNode(id);
    }

    function style(node, prop, value){
        // get/set node style(s)
        //      prop: string or object
        //
        var key, computed;
        if(typeof prop === 'object'){
            // object setter
            for(key in prop){
                if(prop.hasOwnProperty(key)){
                    style(node, key, prop[key]);
                }
            }
            return null;
        }else if(value !== undefined){
            // property setter
            if(typeof value === 'number' && isDimension[prop]){
                value += 'px';
            }
            node.style[prop] = value;

            if(prop === 'userSelect'){
                value = !!value ? 'text' : 'none';
                style(node, {
                    webkitTouchCallout: value,
                    webkitUserSelect: value,
                    khtmlUserSelect: value,
                    mozUserSelect: value,
                    msUserSelect: value
                });
            }
        }

        // getter, if a simple style
        if(node.style[prop]){
            if(isDimension[prop]){
                return parseInt(node.style[prop], 10);
            }
            return node.style[prop];
        }

        // getter, computed
        computed = getComputedStyle(node, prop);
        if(computed[prop]){
            if(/\d/.test(computed[prop])){
                if(!isNaN(parseInt(computed[prop], 10))){
                    return parseInt(computed[prop], 10);
                }
                return computed[prop];
            }
            return computed[prop];
        }
        return '';
    }

    function attr(node, prop, value){
        // get/set node attribute(s)
        //      prop: string or object
        //
        var key;
        if(typeof prop === 'object'){
            for(key in prop){
                if(prop.hasOwnProperty(key)){
                    attr(node, key, prop[key]);
                }
            }
            return null;
        }
        else if(value !== undefined){
            if(prop === 'text' || prop === 'html' || prop === 'innerHTML'){
                node.innerHTML = value;
            }else{
                node.setAttribute(prop, value);
            }
        }

        return node.getAttribute(prop);
    }

    function box(node){
        if(node === window){
            return {
                width: node.innerWidth,
                height: node.innerHeight
            };
        }
        // node dimensions
        // returned object is immutable
        // add scroll positioning and convenience abbreviations
        var
            dimensions = getNode(node).getBoundingClientRect(),
            box = {
                top: dimensions.top,
                right: dimensions.right,
                bottom: dimensions.bottom,
                left: dimensions.left,
                height: dimensions.height,
                h: dimensions.height,
                width: dimensions.width,
                w: dimensions.width,
                scrollY: window.scrollY,
                scrollX: window.scrollX,
                x: dimensions.left + window.pageXOffset,
                y: dimensions.top + window.pageYOffset
            };

        return box;
    }

    function query(node, selector){
        // TODO: Always return one node
        // Deprecate old way of return one or many (or null or [])
        if(!selector){
            selector = node;
            node = document;
        }
        return node.querySelector(selector);
    }

    function queryAll(node, selector){
        if(!selector){
            selector = node;
            node = document;
        }
        var nodes = node.querySelectorAll(selector);

        if(!nodes.length){ return []; }

        // convert to Array and return it
        return Array.prototype.slice.call(nodes);
    }

    function toDom(html, options, parent){
        // create a node from an HTML string
        var node = dom('div', {html: html});
        parent = byId(parent || options);
        if(parent){
            while(node.firstChild){
                parent.appendChild(node.firstChild);
            }
            return node.firstChild;
        }
        if(html.indexOf('<') !== 0){
            return node;
        }
        return node.firstChild;
    }

    function toFrag(html){
        var frag = document.createDocumentFragment();
        frag.innerHTML = html;
        return frag;
    }

    function dom(nodeType, options, parent, prepend){
        // create a node
        // if first argument is a string and starts with <, it is assumed
        // to use toDom, and creates a node from HTML. Optional second arg is
        // parent to append to
        // else:
        //      nodeType: string, type of node to create
        //      options: object with style, className, or attr properties
        //          (can also be objects)
        //      parent: Node, optional node to append to
        //      prepend: truthy, to append node as the first child
        //
        if(nodeType.indexOf('<') === 0){
            return toDom(nodeType, options, parent);
        }

        options = options || {};
        var
            className = options.css || options.className,
            node = document.createElement(nodeType);

        options.html = options.html === undefined ? options.innerHTML : options.html;
        parent = getNode(parent);

        if(className){
            node.className = className;
        }

        if(options.html !== undefined){
            console.log('options.html', options.html);
            node.innerHTML = options.html;
        }

        if(options.cssText){
            node.style.cssText = options.cssText;
        }

        if(options.id){
            node.id = options.id;
        }

        if(options.style){
            style(node, options.style);
        }

        if(options.attr){
            attr(node, options.attr);
        }

        if(parent && isNode(parent)){
            if(prepend && parent.hasChildNodes()){
                parent.insertBefore(node, parent.children[0]);
            }else{
                parent.appendChild(node);
            }
        }

        return node;
    }

    function destroy(node){
        // destroys a node completely
        //
        if(node) {
            destroyer.appendChild(node);
            destroyer.innerHTML = '';
        }
    }

    function clean(node, dispose){
        //	Removes all child nodes
        //		dispose: destroy child nodes
        if(dispose){
            while(node.children.length){
                destroy(node.children[0]);
            }
            return;
        }
        while(node.children.length){
            node.removeChild(node.children[0]);
        }
    }

    function ancestor (node, selector){
        // TODO: replace this with 'closest' and 'matches'
        // gets the ancestor of node based on selector criteria
        // useful for getting the target node when a child node is clicked upon
        //
        // USAGE
        //      on.selector(childNode, '.app.active');
        //      on.selector(childNode, '#thinger');
        //      on.selector(childNode, 'div');
        //	DOES NOT SUPPORT:
        //		combinations of above
        var
            test,
            parent = node;

        if(selector.indexOf('.') === 0){
            // className
            selector = selector.replace('.', ' ').trim();
            test = function(n){
                return n.classList.contains(selector);
            };
        }
        else if(selector.indexOf('#') === 0){
            // node id
            selector = selector.replace('#', '').trim();
            test = function(n){
                return n.id === selector;
            };
        }
        else if(selector.indexOf('[') > -1){
            // attribute
            console.error('attribute selectors are not yet supported');
        }
        else{
            // assuming node name
            selector = selector.toUpperCase();
            test = function(n){
                return n.nodeName === selector;
            };
        }

        while(parent){
            if(parent === document.body || parent === document){ return false; }
            if(test(parent)){ break; }
            parent = parent.parentNode;
        }

        return parent;
    }

    dom.classList = {
        remove: function(node, names){
            toArray(names).forEach(function(name){
                node.classList.remove(name);
            });
        },
        add: function(node, names){
            toArray(names).forEach(function(name){
                node.classList.add(name);
            });
        },
        contains: function(node, names){
            return toArray(names).every(function (name) {
                return node.classList.contains(name);
            });
        },
        toggle: function(node, names, value){
            toArray(names).forEach(function(name){
                node.classList.toggle(name, value);
            });
        }
    };

    function toArray(names){
        if(!names){
            console.error('dom.classList should include a node and a className');
            return [];
        }
        return names.split(' ').map(function (name) {
            return name.trim();
        });
    }

    if (!window.requestAnimationFrame) {
        dom.requestAnimationFrame = function(callback){
            setTimeout(callback, 0);
        };
    }else{
        dom.requestAnimationFrame = function(cb){
            window.requestAnimationFrame(cb);
        };
    }

    dom.clean = clean;
    dom.query = query;
    dom.queryAll = queryAll;
    dom.byId = byId;
    dom.attr = attr;
    dom.box = box;
    dom.style = style;
    dom.destroy = destroy;
    dom.uid = uid;
    dom.isNode = isNode;
    dom.ancestor = ancestor;
    dom.toDom = toDom;
    dom.toFrag = toFrag;

    return dom;
}));
<|endoftext|>


<commit_before>module.exports = {
    "env": {
        "node": true,
        "browser": true,
        "commonjs": true,
        "es6": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "sourceType": "module"
    },
    "rules": {
        "accessor-pairs": "error",
        "array-bracket-spacing": "off",
        "array-callback-return": "error",
        "arrow-body-style": "error",
        "arrow-parens": "error",
        "arrow-spacing": "error",
        "block-scoped-var": "error",
        "block-spacing": "error",
        "brace-style": [
            "error",
            "1tbs"
        ],
        "callback-return": "error",
        "camelcase": "off",
        "comma-dangle": "error",
        "comma-spacing": "off",
        "comma-style": [
            "error",
            "last"
        ],
        "complexity": "error",
        "computed-property-spacing": "error",
        "consistent-return": "error",
        "consistent-this": "error",
        "curly": "off",
        "default-case": "error",
        "dot-location": "error",
        "dot-notation": "error",
        "eol-last": "error",
        "eqeqeq": "off",
        "func-call-spacing": "off",
        "func-names": [
            "error",
            "never"
        ],
        "func-style": [
            "error",
            "declaration"
        ],
        "generator-star-spacing": "error",
        "global-require": "error",
        "guard-for-in": "error",
        "handle-callback-err": "error",
        "id-blacklist": "error",
        "id-length": "error",
        "id-match": "error",
        "indent": "off",
        "init-declarations": "error",
        "jsx-quotes": "error",
        "key-spacing": "error",
        "keyword-spacing": [
            "error",
            {
                "after": true,
                "before": true
            }
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "lines-around-comment": "error",
        "max-depth": "error",
        "max-len": "error",
        "max-lines": "error",
        "max-nested-callbacks": "error",
        "max-params": "error",
        "max-statements": "error",
        "max-statements-per-line": "error",
        "multiline-ternary": "error",
        "new-cap": "error",
        "new-parens": "error",
        "newline-after-var": "off",
        "newline-before-return": "error",
        "newline-per-chained-call": "error",
        "no-alert": "error",
        "no-array-constructor": "error",
        "no-bitwise": "error",
        "no-caller": "error",
        "no-catch-shadow": "error",
        "no-confusing-arrow": "error",
        "no-continue": "error",
        "no-div-regex": "error",
        "no-duplicate-imports": "error",
        "no-else-return": "error",
        "no-empty-function": "error",
        "no-eq-null": "error",
        "no-eval": "error",
        "no-extend-native": "error",
        "no-extra-bind": "error",
        "no-extra-label": "error",
        "no-extra-parens": "error",
        "no-floating-decimal": "error",
        "no-global-assign": "error",
        "no-implicit-coercion": "error",
        "no-implicit-globals": "error",
        "no-implied-eval": "error",
        "no-inline-comments": "error",
        "no-invalid-this": "error",
        "no-iterator": "error",
        "no-label-var": "error",
        "no-labels": "error",
        "no-lone-blocks": "error",
        "no-lonely-if": "error",
        "no-loop-func": "error",
        "no-magic-numbers": "error",
        "no-mixed-operators": "error",
        "no-mixed-requires": "error",
        "no-multi-spaces": "off",
        "no-multi-str": "error",
        "no-multiple-empty-lines": "error",
        "no-negated-condition": "error",
        "no-nested-ternary": "error",
        "no-new": "error",
        "no-new-func": "error",
        "no-new-object": "error",
        "no-new-require": "error",
        "no-new-wrappers": "error",
        "no-octal-escape": "error",
        "no-param-reassign": "error",
        "no-path-concat": "error",
        "no-plusplus": "error",
        "no-process-env": "error",
        "no-process-exit": "error",
        "no-proto": "error",
        "no-prototype-builtins": "error",
        "no-restricted-globals": "error",
        "no-restricted-imports": "error",
        "no-restricted-modules": "error",
        "no-restricted-syntax": "error",
        "no-return-assign": "error",
        "no-script-url": "error",
        "no-self-compare": "error",
        "no-sequences": "error",
        "no-shadow": "error",
        "no-shadow-restricted-names": "error",
        "no-spaced-func": "off",
        "no-sync": "error",
        "no-tabs": "off",
        "no-template-curly-in-string": "error",
        "no-ternary": "error",
        "no-throw-literal": "error",
        "no-trailing-spaces": "error",
        "no-undef-init": "error",
        "no-undefined": "error",
        "no-underscore-dangle": "error",
        "no-unmodified-loop-condition": "error",
        "no-unneeded-ternary": "error",
        "no-unsafe-negation": "error",
        "no-unused-expressions": "error",
        "no-use-before-define": "error",
        "no-useless-call": "error",
        "no-useless-computed-key": "error",
        "no-useless-concat": "error",
        "no-useless-constructor": "error",
        "no-useless-escape": "error",
        "no-useless-rename": "error",
        "no-var": "off",
        "no-void": "error",
        "no-warning-comments": "error",
        "no-whitespace-before-property": "error",
        "no-with": "error",
        "object-curly-newline": "error",
        "object-curly-spacing": "off",
        "object-property-newline": [
            "error",
            {
                "allowMultiplePropertiesPerLine": true
            }
        ],
        "object-shorthand": "error",
        "one-var": "off",
        "one-var-declaration-per-line": "error",
        "operator-assignment": "error",
        "operator-linebreak": "error",
        "padded-blocks": "off",
        "prefer-arrow-callback": "off",
        "prefer-const": "off",
        "prefer-reflect": "error",
        "prefer-rest-params": "error",
        "prefer-spread": "error",
        "prefer-template": "error",
        "quote-props": "off",
        "quotes": "off",
        "radix": "error",
        "require-jsdoc": "off",
        "rest-spread-spacing": "error",
        "semi": "off",
        "semi-spacing": "error",
        "sort-imports": "error",
        "sort-keys": "off",
        "sort-vars": "error",
        "space-before-blocks": "error",
        "space-before-function-paren": "off",
        "space-in-parens": [
            "error",
            "never"
        ],
        "space-infix-ops": "error",
        "space-unary-ops": "error",
        "spaced-comment": [
            "error",
            "always"
        ],
        "strict": "error",
        "template-curly-spacing": "error",
        "unicode-bom": [
            "error",
            "never"
        ],
        "valid-jsdoc": "error",
        "vars-on-top": "error",
        "wrap-iife": "error",
        "wrap-regex": "error",
        "yield-star-spacing": "error",
        "yoda": [
            "error",
            "never"
        ]
    }
};
<commit_msg>add allowForLoopAfterthoughts to no-plusplus of eslint rule<commit_after>module.exports = {
    "env": {
        "node": true,
        "browser": true,
        "commonjs": true,
        "es6": true
    },
    "extends": "eslint:recommended",
    "parserOptions": {
        "sourceType": "module"
    },
    "rules": {
        "accessor-pairs": "error",
        "array-bracket-spacing": "off",
        "array-callback-return": "error",
        "arrow-body-style": "error",
        "arrow-parens": "error",
        "arrow-spacing": "error",
        "block-scoped-var": "error",
        "block-spacing": "error",
        "brace-style": [
            "error",
            "1tbs"
        ],
        "callback-return": "error",
        "camelcase": "off",
        "comma-dangle": "error",
        "comma-spacing": "off",
        "comma-style": [
            "error",
            "last"
        ],
        "complexity": "error",
        "computed-property-spacing": "error",
        "consistent-return": "error",
        "consistent-this": "error",
        "curly": "off",
        "default-case": "error",
        "dot-location": "error",
        "dot-notation": "error",
        "eol-last": "error",
        "eqeqeq": "off",
        "func-call-spacing": "off",
        "func-names": [
            "error",
            "never"
        ],
        "func-style": [
            "error",
            "declaration"
        ],
        "generator-star-spacing": "error",
        "global-require": "error",
        "guard-for-in": "error",
        "handle-callback-err": "error",
        "id-blacklist": "error",
        "id-length": "error",
        "id-match": "error",
        "indent": "off",
        "init-declarations": "error",
        "jsx-quotes": "error",
        "key-spacing": "error",
        "keyword-spacing": [
            "error",
            {
                "after": true,
                "before": true
            }
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "lines-around-comment": "error",
        "max-depth": "error",
        "max-len": "error",
        "max-lines": "error",
        "max-nested-callbacks": "error",
        "max-params": "error",
        "max-statements": "error",
        "max-statements-per-line": "error",
        "multiline-ternary": "error",
        "new-cap": "error",
        "new-parens": "error",
        "newline-after-var": "off",
        "newline-before-return": "error",
        "newline-per-chained-call": "error",
        "no-alert": "error",
        "no-array-constructor": "error",
        "no-bitwise": "error",
        "no-caller": "error",
        "no-catch-shadow": "error",
        "no-confusing-arrow": "error",
        "no-continue": "error",
        "no-div-regex": "error",
        "no-duplicate-imports": "error",
        "no-else-return": "error",
        "no-empty-function": "error",
        "no-eq-null": "error",
        "no-eval": "error",
        "no-extend-native": "error",
        "no-extra-bind": "error",
        "no-extra-label": "error",
        "no-extra-parens": "error",
        "no-floating-decimal": "error",
        "no-global-assign": "error",
        "no-implicit-coercion": "error",
        "no-implicit-globals": "error",
        "no-implied-eval": "error",
        "no-inline-comments": "error",
        "no-invalid-this": "error",
        "no-iterator": "error",
        "no-label-var": "error",
        "no-labels": "error",
        "no-lone-blocks": "error",
        "no-lonely-if": "error",
        "no-loop-func": "error",
        "no-magic-numbers": "error",
        "no-mixed-operators": "error",
        "no-mixed-requires": "error",
        "no-multi-spaces": "off",
        "no-multi-str": "error",
        "no-multiple-empty-lines": "error",
        "no-negated-condition": "error",
        "no-nested-ternary": "error",
        "no-new": "error",
        "no-new-func": "error",
        "no-new-object": "error",
        "no-new-require": "error",
        "no-new-wrappers": "error",
        "no-octal-escape": "error",
        "no-param-reassign": "error",
        "no-path-concat": "error",
        "no-plusplus":  [
          "error",
          {
            "allowForLoopAfterthoughts": true
          }
        ],
        "no-process-env": "error",
        "no-process-exit": "error",
        "no-proto": "error",
        "no-prototype-builtins": "error",
        "no-restricted-globals": "error",
        "no-restricted-imports": "error",
        "no-restricted-modules": "error",
        "no-restricted-syntax": "error",
        "no-return-assign": "error",
        "no-script-url": "error",
        "no-self-compare": "error",
        "no-sequences": "error",
        "no-shadow": "error",
        "no-shadow-restricted-names": "error",
        "no-spaced-func": "off",
        "no-sync": "error",
        "no-tabs": "off",
        "no-template-curly-in-string": "error",
        "no-ternary": "error",
        "no-throw-literal": "error",
        "no-trailing-spaces": "error",
        "no-undef-init": "error",
        "no-undefined": "error",
        "no-underscore-dangle": "error",
        "no-unmodified-loop-condition": "error",
        "no-unneeded-ternary": "error",
        "no-unsafe-negation": "error",
        "no-unused-expressions": "error",
        "no-use-before-define": "error",
        "no-useless-call": "error",
        "no-useless-computed-key": "error",
        "no-useless-concat": "error",
        "no-useless-constructor": "error",
        "no-useless-escape": "error",
        "no-useless-rename": "error",
        "no-var": "off",
        "no-void": "error",
        "no-warning-comments": "error",
        "no-whitespace-before-property": "error",
        "no-with": "error",
        "object-curly-newline": "error",
        "object-curly-spacing": "off",
        "object-property-newline": [
            "error",
            {
                "allowMultiplePropertiesPerLine": true
            }
        ],
        "object-shorthand": "error",
        "one-var": "off",
        "one-var-declaration-per-line": "error",
        "operator-assignment": "error",
        "operator-linebreak": "error",
        "padded-blocks": "off",
        "prefer-arrow-callback": "off",
        "prefer-const": "off",
        "prefer-reflect": "error",
        "prefer-rest-params": "error",
        "prefer-spread": "error",
        "prefer-template": "error",
        "quote-props": "off",
        "quotes": "off",
        "radix": "error",
        "require-jsdoc": "off",
        "rest-spread-spacing": "error",
        "semi": "off",
        "semi-spacing": "error",
        "sort-imports": "error",
        "sort-keys": "off",
        "sort-vars": "error",
        "space-before-blocks": "error",
        "space-before-function-paren": "off",
        "space-in-parens": [
            "error",
            "never"
        ],
        "space-infix-ops": "error",
        "space-unary-ops": "error",
        "spaced-comment": [
            "error",
            "always"
        ],
        "strict": "error",
        "template-curly-spacing": "error",
        "unicode-bom": [
            "error",
            "never"
        ],
        "valid-jsdoc": "error",
        "vars-on-top": "error",
        "wrap-iife": "error",
        "wrap-regex": "error",
        "yield-star-spacing": "error",
        "yoda": [
            "error",
            "never"
        ]
    }
};
<|endoftext|>


<commit_before>"use strict";
let platform = require('git-node-platform');
let jsGit = require('../.')(platform);
let fsDb = require('git-fs-db')(platform);
let fs = platform.fs;
let run = require('gen-run');

// Create a filesystem backed bare repo
let repo = jsGit(fsDb(fs("test.git")));

let mock = require('./mock.js');

run(function *() {
  yield repo.setBranch("master");
  console.log("Git database Initialized");

  let head;
  console.log(yield* map(mock.commits, function* (files, message) {
    return head = yield repo.saveAs("commit", {
      tree: yield repo.saveAs("tree", yield* map(files, function* (contents) {
        return {
          mode: 33188, // 0100644,
          hash: yield repo.saveAs("blob", contents)
        };
      })),
      parent: head,
      author: mock.author,
      committer: mock.committer,
      message: message
    });
  }));

  yield repo.updateHead(head);
  console.log("Done");

});

function* map(object, onItem) {
  let obj = {};
  for (let key in object) {
    let value = object[key];
    obj[key] = yield* onItem(value, key);
  }
  return obj;
}

<commit_msg>Use new octal syntax in comment<commit_after>"use strict";
let platform = require('git-node-platform');
let jsGit = require('../.')(platform);
let fsDb = require('git-fs-db')(platform);
let fs = platform.fs;
let run = require('gen-run');

// Create a filesystem backed bare repo
let repo = jsGit(fsDb(fs("test.git")));

let mock = require('./mock.js');

run(function *() {
  yield repo.setBranch("master");
  console.log("Git database Initialized");

  let head;
  console.log(yield* map(mock.commits, function* (files, message) {
    return head = yield repo.saveAs("commit", {
      tree: yield repo.saveAs("tree", yield* map(files, function* (contents) {
        return {
          mode: 33188, // 0o100644,
          hash: yield repo.saveAs("blob", contents)
        };
      })),
      parent: head,
      author: mock.author,
      committer: mock.committer,
      message: message
    });
  }));

  yield repo.updateHead(head);
  console.log("Done");

});

function* map(object, onItem) {
  let obj = {};
  for (let key in object) {
    let value = object[key];
    obj[key] = yield* onItem(value, key);
  }
  return obj;
}

<|endoftext|>