How to use the stampit.init function in stampit

To help you get started, we’ve selected a few stampit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sweet-js / sweet-core / src / stamps.js View on Github external
import stampit from "stampit";

export const Cloneable = stampit.init(({ instance, stamp }) => {
  // Avoid adding the same method to the prototype twice.
  if (!stamp.fixed.methods.clone) {
    stamp.fixed.methods.clone = function () {
      return stamp(this);
    };
  }
});

export const Frozen = stampit().init(({instance}) => {
  Object.freeze(instance);
});
github char0n / page-objects / src / todo-list-item.page.js View on Github external
'use strict';

const stampit = require('stampit');
const { By } = require('selenium-webdriver');


const TodoListItem = stampit
  .init(function ({ webElement }) {
    this.isComplete = async function isComplete() {
      const TodoList = require('./todo-list.page');
      const listElement = await webElement.findElement(By.xpath('..'));
      const todoList = TodoList({ webElement: listElement });

      return todoList.isComplete();
    };

    this.delete = async function _delete() {
      const button = await webElement.findElement(By.className('remove'));

      return button.click();
    };

    this.complete = async function complete() {
github char0n / page-objects / src / todo-list-item-creator.page.js View on Github external
'use strict';

const stampit = require('stampit');
const { By } = require('selenium-webdriver');


const AddButton = stampit.init(function ({ driver }) {
  const findElement = () => driver.findElement(By.css('header button'));

  this.isEnabled = async function isEnabled() {
    const element = await findElement();

    return element.isEnabled();
  };

  this.click = async function click() {
    const element = await findElement();

    return element.click();
  };
});

stampit

Create objects from reusable, composable behaviors.

MIT
Latest version published 4 years ago

Package Health Score

62 / 100
Full package analysis