How to use replicator - 7 common examples

To help you get started, we’ve selected a few replicator 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 DevExpress / testcafe / src / client-functions / replicator.js View on Github external
export function createReplicator (transforms) {
    // NOTE: we will serialize replicator results
    // to JSON with a command or command result.
    // Therefore there is no need to do additional job here,
    // so we use identity functions for serialization.
    const replicator = new Replicator({
        serialize:   identity,
        deserialize: identity
    });

    return replicator.addTransforms(transforms);
}
github DevExpress / testcafe / src / client / driver / command-executors / execute-hybrid-function / replicator.js View on Github external
import Replicator from 'replicator';
import evalFunction from './eval-function';

var identityFn = val => val;

// NOTE: we will serialize replicator results
// to JSON with a command or command result.
// Therefore there is no need to do additional job here,
// so we use identity functions for serialization.
var replicator = new Replicator({
    serialize:   identityFn,
    deserialize: identityFn
});

export default replicator.addTransforms([
    {
        type: 'Function',

        shouldTransform () {
            return false;
        },

        fromSerializable: evalFunction
    }
]);
github DevExpress / testcafe / src / api / common / hybrid / index.js View on Github external
import { compileHybridFunction, compileFunctionArgumentOfHybridFunction } from '../../../compiler/es-next/hybrid-function';
import { ExecuteHybridFunctionCommand } from '../../../test-run/commands';
import { APIError } from '../../../errors/runtime';
import MESSAGE from '../../../errors/runtime/message';
import getCallsite from '../../../errors/get-callsite';

const DEFAULT_CALLSITE_NAMES = {
    instantiation: 'Hybrid',
    execution:     '__$$hybridFunction$$'
};

// NOTE: we will serialize replicator results
// to JSON with a command or command result.
// Therefore there is no need to do additional job here,
// so we use identity functions for serialization.
var replicator = new Replicator({
    serialize:   identity,
    deserialize: identity
});

replicator.addTransforms([
    {
        type: 'Function',

        shouldTransform (type) {
            return type === 'function';
        },

        toSerializable (fn) {
            var isHybrid = !!fn[compiledCode];

            if (isHybrid)
github DevExpress / testcafe / src / client / driver / command-executors / execute-hybrid-function / index.js View on Github external
import hammerhead from '../../deps/hammerhead';
import DriverStatus from '../../status';
import Replicator from 'replicator';
import evalFunction from './eval-function';
import { UncaughtErrorInClientExecutedCode } from '../../../../errors/test-run';

const HYBRID_COMPILED_CODE = '[[hybridCompiledCode]]';

var Promise    = hammerhead.Promise;
var identityFn = val => val;

// NOTE: we will serialize replicator results
// to JSON with a command or command result.
// Therefore there is no need to do additional job here,
// so we use identity functions for serialization.
var replicator = new Replicator({
    serialize:   identityFn,
    deserialize: identityFn
});

replicator.addTransforms([
    {
        type: 'Function',

        shouldTransform (type) {
            return type === 'function';
        },

        toSerializable (fn) {
            return {
                isHybridCode: !!fn[HYBRID_COMPILED_CODE],
                fnCode:       fn[HYBRID_COMPILED_CODE] || fn.toString()
github DevExpress / testcafe / src / client / driver / command-executors / client-functions / replicator.js View on Github external
export function createReplicator (transforms) {
    // NOTE: we will serialize replicator results
    // to JSON with a command or command result.
    // Therefore there is no need to do additional job here,
    // so we use identity functions for serialization.
    const replicator = new Replicator({
        serialize:   identity,
        deserialize: identity
    });

    return replicator.addTransforms(transforms);
}
github frontarm / demoboard / packages / demoboard-messaging / src / replicator / index.ts View on Github external
function getReplicator() {
  if (!replicator) {
    replicator = new Replicator()
    replicator.addTransforms(transforms)
  }
  return replicator
}
export function encode(value: any): string {
github frontarm / demoboard / packages / demoboard-messaging / src / replicator / index.ts View on Github external
function getReplicatorWithPromises() {
  if (!replicatorWithPromises) {
    replicatorWithPromises = new Replicator()
    replicatorWithPromises.addTransforms(
      (transforms as any).concat(promiseTransform),
    )
  }
  return replicatorWithPromises
}

replicator

Advanced JavaScript objects serialization.

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular replicator functions