Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parrot-core

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parrot-core

Common Parrot functionality.

  • 4.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
480
decreased by-51.86%
Maintainers
2
Weekly downloads
 
Created
Source

Parrot-Core

parrot-core abstracts the matching, logging, and resolving functionality of Parrot away from each implementation. parrot-middleware and parrot-fetch use parrot-core and any new implementations could extend parrot-core in a similar way.

Example Implementation

import Parrot from 'parrot-core';

class ParrotNew extends Parrot {
  constructor(scenarios) {
    super(scenarios);
    // any constructor logic that is needed
  }

  normalizeRequest = request => {
    // conform incoming requests to match the scenarios structure
  };

  resolver = request => response => {
    // resolve the matched response to the implementation platform
  };
}

export default ParrotNew;

Access Methods

parrot-core also defines several methods that can be used to interact with the scenarios that are passed in.

getActiveScenario()

Returns the name of the currently active scenario.

setActiveScenario(name)

Sets the currently active scenario.

Arguments
  • name (String): Scenario name.

getScenarios()

Returns an array of scenario objects.

setScenarios(scenarios)

Sets scenarios as the array of available scenarios.

Arguments
  • scenarios (Array or Object): Scenarios descriptor.

getScenario(name)

Returns the scenario object with matching name.

Arguments
  • name (String): Scenario name.

setScenario(name, mocks)

Sets the mocks for scenario with matching name.

Arguments
  • name (String): Scenario name.
  • mocks (Array): Array of mock objects.

getMock(name, index)

Returns the mock at index for scenario with matching name.

Arguments
  • name (String): Scenario name.
  • index (Number): Mock index.

setMock(name, index, mock)

Sets the mock at index for scenario with matching name.

Arguments
  • name (String): Scenario name.
  • index (Number): Mock index.
  • mock (Object): Mock object.

FAQs

Package last updated on 25 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc