Skip to content
プロジェクト

概要

JavaScript のリファクタリングを支援するシンプルなツール

その他のプロジェクト

この数値の測り方

計測したスター増加

24時間
0
7日間
0
15日間
0
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

What is this?

kratko.js helps you refactor Javascript. It takes an object and collects information about it. It lets you see which objects have too many methods, which methods do too many things, and accept too many arguments.

How do I use it?

kratko.js defines 2 global objects — Kratko and TableViewer. Kratko is used for getting stats of an object — lengths of methods, lengths of method arguments, as well their average, minimum and maximum values. TableViewer provides simple UI to view those stats via HTML table.

Which stats do I get?

Kratko.getStatsFor() returns an object with stats that looks like this:

{
  methods: {
    name: {
      methodString: ...,
      length: ...,
      argsLength: ...
    }
  },

  totalMethodLength: ...,

  minMethodLength: ...,
  maxMethodLength: ...,

  totalArgsLength: ...,

  minArgsLength: ...,
  maxArgsLength: ...,

  numMethods: ...
}

For example, if we have an object with 2 methods foo and bar:

var obj = {
  foo: function(x, y) {
    return x + y;
  },
  bar: function(a, b, c, d, e, f, g) {
    if (true) {
      // some comment
      alert(123);
    }
  }
};

Here's an output returned by Kratko.getStatsFor:

{
  methods: {
    foo: {
      methodString: 'function (x, y) {\n  return x + y;\n}',
      length: 1,
      argsLength: 2
    },
    bar: {
      methodString: 'function (a, b, c, d, e, f, g) {\n  if (true) {\n    //some comment\n    alert(123);\n  }}',
      length: 3,
      argsLength: 7
    }
  },
  
  totalMethodLength: 4,
  minMethodLength: 1,
  maxMethodLength: 3,
  
  totalArgsLength: 9,
  minArgsLength: 2,
  maxArgsLength: 7,
  
  numMethods: 2
}

Bitdeli Badge

関連プロジェクトを探す

読み込み中…