• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript ramda.clone函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中ramda.clone函数的典型用法代码示例。如果您正苦于以下问题:TypeScript clone函数的具体用法?TypeScript clone怎么用?TypeScript clone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了clone函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: rowGenerator

export function rowGenerator(state: State, table: string, schema: RelationTree): Route[] {

  let history: History = R.clone(state.history || []);

  if (history.length >= state.options.relationLimit) {
    return [];
  }

  let last = R.last(history);

  let relation = schema[table].relations[last && last['table']];
  let identifier = `${schema[table].model}_id`;
  if (relation) {
    history.push({
      type: 'row',
      table: table,
      model: schema[table].model
    });
  }
  else {
    history[0] = {
      type: 'row',
      table: table,
      model: schema[table].model,
      identifier: identifier
    };
  }

  let identifierString = state.options.idFormat === 'colons' ?
    `:${identifier}` : `{${identifier}}`;

  let newPath = relation ?
    `${state.path}/${schema[table].model}` :  `${state.path}/${identifierString}`;

  let newState = {
    options: state.options,
    path: newPath,
    history: history
  };

  let tables = R.flatten(Object.keys(schema[table].relations).map((relation) => {
    if (schema[table].relations[relation] === 'one') {
      return rowGenerator(newState, relation, schema);
    }
    else {
      return tableGenerator(newState, relation, schema);
    }
  }));

  return R.concat(
    scopes.row.methods.map((method) => {
      return {
        path: newPath,
        method: method,
        history: history
      };
    }),
    tables
  );
};
开发者ID:repositive,项目名称:hapi-path-generator,代码行数:60,代码来源:pathGenerator.ts


示例2: dialogReducer

export default function dialogReducer(
  state: dialogReducerState = {
    help_open: false,
    settings_open: false,
    add_project_open: false,
    delete_file_open: false,
    delete_project_open: false,
    rename_file_open: false,
    copy_file_open: false,
    add_file_open: false,
    add_test_open: false,
    add_question_open: false,
    reset_open: false,
    archive_open: false
  },
  action: dialogAction) {
  state = clone(state);
  switch (action.type) {
    case dialogActions.open:
      state[action.payload] = true;
      break;
    case dialogActions.close:
      state[action.payload] = false;
      break;
    case dialogActions.toggle:
      state[action.payload] = !state[action.payload];
      break;
  }
  return state;
}
开发者ID:cs136,项目名称:seashell,代码行数:30,代码来源:dialogReducer.ts


示例3: pathGenerator

  return pathGenerator(schema, options).map((route: HandleRoute) => {
    let state = R.clone(route.history[route.history.length - 1]);
    let model = sequelize.models[state.model];

    let queryParser = sequelizeQueryParser(schema, model);
    let queryGenerator = sequelizeQueryGenerator(sequelize, route.history);

    route.query = function(context) {
      // console.log(context);
      context.query = queryParser(context.query || {});
      context.method = route.method;

      if (route.method === 'get') {
        context.query.limit = context.query.limit || options.defaultLimit;
        if (context.query.limit > options.maxItems) {
          context.query.limit = options.maxItems;
        }
      }

      let query = queryGenerator(context);

      let base;

      if (context.query.scope) {
        base = sequelize.models[state.model].scope(context.query.scope);
      }
      else {
        base = sequelize.models[state.model];
      }

      let f = base[methodMap[state.type][route.method]];

      let fParams = [query];

      if (R.contains(route.method, ['put', 'post', 'update'])) {
        fParams.unshift(context.payload);
      }

      return f.apply(base, fParams).then((response) => {
        if (route.method === 'put') {
          let updated = response[1];
          if (state.type === 'row') {
            return updated.length === 0 ? null : updated[0];
          }
          else {
            return updated;
          }
        }
        if (route.method === 'delete') {
          return {id: context.identifiers[state.identifier]};
        }
        else {
          return response;
        }
      });
    };

    return route;
  });
开发者ID:repositive,项目名称:hapi-path-generator,代码行数:59,代码来源:sequelizePaths.ts


示例4: loadArgs

export function loadArgs(args: string[], defaults = DEFAULTS) {
  let config = R.clone(defaults);

  let argv = minimist(args, OPTIONS);
  if (argv['config']) {
    let file = argv['config'];
    if (typeof file === 'string') config = loadFile(file, config);
  }

  let object: any = {};

  object.client = {};
  if (argv['client']) object.client.name = argv['client'];
  if (argv['client-config']) {
    let clientConfig = argv['client-config'];
    if (typeof clientConfig === 'string') {
      object.client.config = JSON.parse(clientConfig);
    }
  }
  if (argv['journal-table']) object.client.journalTable = argv['journal-table'];

  if (argv['directory']) object.files = {directory: argv['directory']};

  if (argv['status']) object.command = 'status';
  if (argv['migrations']) object.command = 'migrations';
  if (argv['journal']) object.command = 'journal';
  if (argv['create']) object.command = 'create';
  if (argv['apply']) object.command = 'apply';
  if (argv['revert']) object.command = 'revert';
  if (argv['help']) object.command = 'help';
  if (argv['version']) object.command = 'version';
  let command: any = {};
  object.commands = {[object.command]: command};

  if (argv['id']) command.id = argv['id'];

  if (argv['long']) command.long = true;

  if (argv['combined']) command.split = false;
  if (argv['split']) command.split = true;

  command.templatePaths = {};
  if (argv['template']) command.templatePaths.combined = argv['template'];
  if (argv['up-template']) command.templatePaths.up = argv['up-template'];
  if (argv['down-template']) command.templatePaths.down = argv['down-template'];

  if (argv['all']) command.method = 'all';
  if (argv['each']) command.method = 'each';
  if (argv['dry']) command.method = 'dry';

  if (argv['pending']) command.pending = true;
  if (argv['to']) command.to = argv['to'];
  if (argv['number']) command.number = argv['number'];

  if (argv['_'].length) command.name = argv['_'].join('-');

  return loadObject(object, config);
}
开发者ID:programble,项目名称:careen,代码行数:58,代码来源:args.ts


示例5: constructors

function constructors(state = [], action): Array<Constructor> {
    // CREATE A NEW TEST CONTROLER

    let newConstructorcopy = Array.from(state);

    switch (action.type) {
        case constants.CREATE_NEW_CONSTRUCTOR:

            newConstructorcopy.push(R.merge(action.elements, {

                browsers: R.clone(getState("browsersSelect"))

            }));

            return newConstructorcopy;
        default:
            return state;
    }
}
开发者ID:thehachez,项目名称:maduk,代码行数:19,代码来源:index.ts


示例6: browsersSelect

function browsersSelect(
    state: BrowsersDef = Object.freeze(initialState.browsersSelect),
    action: {
        type: string,
        payload: {
            id?: string,
            value?: string,
            browser?: string
        }
    }): BrowsersDef {
    // MANAGE THE BROWSERS ICONS 

    let browsersSelectCopy: BrowsersDef;

    switch (action.type) {

        case constants.SET_BROWSERS_FOR_TESTS:
            /* 
             * CHANGE THE ASPECT FILTER AND STATE FOR BROWSERS ITEMS
            */

            browsersSelectCopy = R.clone(state);
            browsersSelectCopy[action.payload.browser] = !browsersSelectCopy[action.payload.browser];
            return browsersSelectCopy;

        case constants.CONSTRUCTOR_FLOAT_CLOSE:
            /* 
             * WHEN THE CONSTRUCTOR FLOAT IS CLOSED DESTROY THE GHOST CONTRUCTOR
            */

            // return the init model state
            return initialState.browsersSelect;

        default:
            return state;
    }
}
开发者ID:thehachez,项目名称:maduk,代码行数:37,代码来源:index.ts


示例7: tableGenerator

export function tableGenerator(state: State, table: string, schema: RelationTree): Route[] {

  let history = R.clone(state.history || []);

  if (history.length >= state.options.relationLimit || (state.path || '').indexOf(table) !== -1) {
    return [];
  }
  else {
    let useRoot = history.length > 0 ? 'methods' : 'rootMethods';

    history.push({
      type: 'table',
      table: table,
      model: schema[table].model
    });
    let newPath = `${state.path || state.options.prefix}/${table}`;
    let newState = {
      options: state.options,
      path: newPath,
      history: history
    };

    let rows = rowGenerator(newState, table, schema);

    return R.concat(
      scopes.table[useRoot].map((method: string) => {
        return {
          path: newPath,
          method: method,
          history: history
        };
      }),
      rows
    );
  }
};
开发者ID:repositive,项目名称:hapi-path-generator,代码行数:36,代码来源:pathGenerator.ts


示例8: loadObject

export function loadObject(object: any, defaults = DEFAULTS): Config {
  let config = R.clone(defaults);

  if (object.hasOwnProperty('client')) {
    let client = object.client;
    ConfigTypeError.assert('client', 'object', client);

    setKey(config.client, ['client', 'name'], 'string', client);
    setKey(config.client, ['client', 'config'], 'object', client);
    setKey(config.client, ['client', 'journalTable'], 'string', client);
  }

  if (object.hasOwnProperty('files')) {
    ConfigTypeError.assert('files', 'object', object.files);

    setKey(config.files, ['files', 'directory'], 'string', object.files);
  }

  setEnumKey(config, ['command'], Command, object);

  if (object.hasOwnProperty('commands')) {
    let commands = object.commands;
    ConfigTypeError.assert('commands', 'object', commands);

    if (commands.hasOwnProperty('migrations')) {
      let migrations = commands.migrations;
      ConfigTypeError.assert('commands.migrations', 'object', migrations);

      setKey(
        config.commands.migrations,
        ['commands', 'migrations', 'long'],
        'boolean',
        migrations
      );
      setKey(
        config.commands.migrations,
        ['commands', 'migrations', 'id'],
        'string',
        migrations
      );
    }

    if (commands.hasOwnProperty('status')) {
      let status = commands.status;
      ConfigTypeError.assert('commands.status', 'object', status);

      setKey(
        config.commands.status,
        ['commands', 'status', 'id'],
        'string',
        status
      );
    }

    if (commands.hasOwnProperty('journal')) {
      let journal = commands.journal;
      ConfigTypeError.assert('commands.journal', 'object', journal);

      setKey(
        config.commands.journal,
        ['commands', 'journal', 'id'],
        'string',
        journal
      );
    }

    if (commands.hasOwnProperty('create')) {
      let create = commands.create;
      ConfigTypeError.assert('commands.create', 'object', create);

      setKey(
        config.commands.create,
        ['commands', 'create', 'generateID'],
        'function',
        create
      );
      setKey(
        config.commands.create,
        ['commands', 'create', 'split'],
        'boolean',
        create
      );
      setKey(
        config.commands.create,
        ['commands', 'create', 'name'],
        'string',
        create
      );

      if (create.hasOwnProperty('templatePaths')) {
        let templatePaths = create.templatePaths;
        ConfigTypeError.assert('commands.create.templatePaths', 'object', templatePaths);

        setKey(
          config.commands.create.templatePaths,
          ['commands', 'create', 'templatePaths', 'combined'],
          'string',
          templatePaths
        );
        setKey(
//.........这里部分代码省略.........
开发者ID:programble,项目名称:careen,代码行数:101,代码来源:load.ts


示例9: queryGenerator

module.exports = R.curry(function queryGenerator(sequelize, pathHistory, context) {
  let history = R.clone(pathHistory);
  return generator(sequelize, history, context);
});
开发者ID:repositive,项目名称:hapi-path-generator,代码行数:4,代码来源:queryGenerator.ts



注:本文中的ramda.clone函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript ramda.compose函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ramda.chain函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap