All Projects → ziyasal → Scientist.js

ziyasal / Scientist.js

Licence: unlicense
🔬 A JavaScript interpretation of the Ruby library Scientist, a library for carefully refactoring critical paths.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Scientist.js

Electron Reloader
Simple auto-reloading for Electron apps during development
Stars: ✭ 463 (-22.83%)
Mutual labels:  npm-package
Synp
Convert yarn.lock to package-lock.json and vice versa
Stars: ✭ 510 (-15%)
Mutual labels:  npm-package
Coca
Coca is a toolbox which is design for legacy system refactoring and analysis, includes call graph, concept analysis, api tree, design patterns suggest. Coca 是一个用于系统重构、系统迁移和系统分析的瑞士军刀。它可以分析代码中的测试坏味道、模块化分析、行数统计、分析调用与依赖、Git 分析以及自动化重构等。
Stars: ✭ 576 (-4%)
Mutual labels:  refactoring
Ignite Ui
Ignite UI by Infragistics
Stars: ✭ 468 (-22%)
Mutual labels:  npm-package
Strip Json Comments
Strip comments from JSON. Lets you use comments in your JSON files!
Stars: ✭ 492 (-18%)
Mutual labels:  npm-package
Command Line Args
A mature, feature-complete library to parse command-line options.
Stars: ✭ 525 (-12.5%)
Mutual labels:  npm-package
Cloudinary npm
Cloudinary NPM for node.js integration
Stars: ✭ 450 (-25%)
Mutual labels:  npm-package
Scalafix
Refactoring and linting tool for Scala
Stars: ✭ 597 (-0.5%)
Mutual labels:  refactoring
Crypto Hash
Tiny hashing module that uses the native crypto API in Node.js and the browser
Stars: ✭ 501 (-16.5%)
Mutual labels:  npm-package
Capture Website Cli
Capture screenshots of websites from the command-line
Stars: ✭ 545 (-9.17%)
Mutual labels:  npm-package
Vanilla Framework
From community websites to web applications, this CSS framework will help you achieve a consistent look and feel.
Stars: ✭ 476 (-20.67%)
Mutual labels:  npm-package
Type Fest
A collection of essential TypeScript types
Stars: ✭ 6,623 (+1003.83%)
Mutual labels:  npm-package
3rs Of Software Architecture
A guide on how to write readable, reusable, and refactorable software
Stars: ✭ 525 (-12.5%)
Mutual labels:  refactoring
Tfjs Yolo Tiny
In-Browser Object Detection using Tiny YOLO on Tensorflow.js
Stars: ✭ 465 (-22.5%)
Mutual labels:  npm-package
Node Tensorflow
Node.js + TensorFlow
Stars: ✭ 581 (-3.17%)
Mutual labels:  npm-package
Electron Better Ipc
Simplified IPC communication for Electron apps
Stars: ✭ 463 (-22.83%)
Mutual labels:  npm-package
Normalize Url
Normalize a URL
Stars: ✭ 512 (-14.67%)
Mutual labels:  npm-package
Pretty Ms
Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`
Stars: ✭ 599 (-0.17%)
Mutual labels:  npm-package
Phpactor
PHP completion, refactoring, introspection tool and language server.
Stars: ✭ 591 (-1.5%)
Mutual labels:  refactoring
Jedi
Awesome autocompletion, static analysis and refactoring library for python
Stars: ✭ 5,037 (+739.5%)
Mutual labels:  refactoring

scientist.js

🔬 A JavaScript interpretation of the Ruby library Scientist, a library for carefully refactoring critical paths.

Build Status Coverage Status

Install

npm install scientist.js

How do I science?

Let's pretend you're changing the way you handle permissions in a large web app. Tests can help guide your refactoring, but you really want to capture the current and refactored behaviours under load.

ES6 Sample

import {Experiment, Result} from 'scientist.js';

import Permission from './permission';
import Model from './model';

class MyWidget {
    constructor() {
        this.model = new Model();
    }

    allows(user) {
        var experiment = new Experiment("widget-permissions");
        experiment.use(() => this.model.checkUser(user).valid); // old way
        experiment.try(() => user.can(Permission.Read, this.model)); // new way

        return experiment.run();
    }
}

Use use(..) to wrap the existing original behaviour, and use try(..) to wrap the new behaviour. experiment.run(); will always return the result of the use block, but it does a bunch of stuff behind the scenes:

  • It decides whether or not to run the try block
  • Randomises order to execute try and use blocks
  • Measures the duration of both behaviours
  • Swallows (but records) any exceptions raised in the try block and
  • Set a condition to filter calls to try

Upcoming features (these already exist in the Ruby library):

  • Compares the result of try to the result of use,
  • Publishes all this information.

The use block is called the control. The try block is called the candidate.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].