当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Map.isMap方法代码示例

本文整理汇总了TypeScript中Immutable.Map.isMap方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Map.isMap方法的具体用法?TypeScript Map.isMap怎么用?TypeScript Map.isMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Immutable.Map的用法示例。


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

示例1: to_key

export function to_key(s: any): string {
  if (immutable.Map.isMap(s)) {
    s = s.toJS();
  }
  // NOTE: s is not undefined.
  return json_stable(s) as string;
}
开发者ID:DrXyzzy,项目名称:smc,代码行数:7,代码来源:util.ts

示例2: function

  protected call<T>(method, url, data: any = {}) {
    if(Map.isMap(data)) {
      data = data.toObject();
    }

    // Api prefix
    url = "/api/" + url;

    const options = {method: method, url, json: true, body: JSON.stringify(data)};

    const observable = new Subject<T>();

    console.log(`$$$Making a ${method} request to ${url}`);
    console.log("$$$Data", data);

    request<any>(options, function(err, response) {
      if(err) {
        observable.onError(err);
      } else {
        observable.onNext(response.body);        
      }
    })

    return observable;
  }
开发者ID:dghijben,项目名称:dashboard,代码行数:25,代码来源:Api.ts

示例3: it

  it('can compose Immutable::Map initial states', () => {
    const state = compose(fromJS({a: 1}), fromJS({b: 1}), fromJS({c: 1}));
    expect(Map.isMap(state)).to.be.true;

    const plain = state.toJS();
    expect(plain).not.to.be.null;
    expect(plain).to.deep.equal({a: 1, b: 1, c: 1});
  });
开发者ID:danielfigueiredo,项目名称:ng2-redux-form,代码行数:8,代码来源:compose-reducers.test.ts

示例4:

 var options = (function () {
     if (_.isString(name)) {
         return {app: name};
     }
     if (Immutable.Map.isMap(name)) {
         return name.toJS();
     }
     return {};
 })();
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:9,代码来源:utils.ts

示例5:

 value.forEach(function(value) {
     if (_.isString(value)) {
         globs.push(value);
     } else {
         if (Map.isMap(value)) {
             objs.push(value);
         }
     }
 });
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:9,代码来源:cli-options.ts

示例6: addToFilesOption

export function addToFilesOption(incoming: BsTempOptions): TransformResult {
    if (!incoming.get("watch")) {
        return [incoming, []];
    }

    let serverPaths = [];

    const fromServeStatic = incoming
        .get("serveStatic", List([]))
        .toArray();
    const ssPaths = fromServeStatic
        .reduce((acc, ss) => {
            if (typeof ss === "string") {
                return acc.concat(ss);
            }
            if (ss.dir && typeof ss.dir === "string") {
                return acc.concat(ss);
            }
            return acc;
        }, []);

    ssPaths.forEach(p => serverPaths.push(p));

    const server = incoming.get("server");
    if (server) {
        if (server === true) {
            serverPaths.push(".");
        }
        if (typeof server === "string") {
            serverPaths.push(server);
        }
        if (
            List.isList(server) &&
            server.every(x => typeof x === "string")
        ) {
            server.forEach(s => serverPaths.push(s));
        }
        if (Map.isMap(server)) {
            const baseDirProp = server.get("baseDir");
            const baseDirs = List([]).concat(baseDirProp).filter(Boolean);
            baseDirs.forEach(s => serverPaths.push(s));
        }
    }

    const output = incoming.update("files", files => {
        return List([])
            .concat(files, serverPaths)
            .filter(Boolean);
    });
    return [output, []];
}
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:51,代码来源:addToFilesOption.ts

示例7: TypeError

  Object.keys(bundle).map(key => {
    if (isJSONKey(key)) {
      if (ImmutableMap.isMap(bundle[key])) {
        bundle[key] = bundle[key].toJS();
      }
      return bundle;
    }

    const data = bundle[key];

    if (typeof data === "string" || Array.isArray(data)) {
      bundle[key] = remultiline(data);
      return bundle;
    }
    throw new TypeError(
      `Data for ${key} is expected to be a string or an Array of strings`
    );
  });
开发者ID:kelleyblackmore,项目名称:nteract,代码行数:18,代码来源:v4.ts

示例8: resolveOne

/**
 * @param {string|Immutable.Map} item
 * @returns {Map}
 */
function resolveOne (item) {
    /**
     * If only a string was given, eg plugins: ['my-plugin']
     * just use node's require to bring in the module with default args
     */
    if (isString(item)) {
        return Imm.fromJS(resolvePluginFromString(item));
    }

    /**
     * If a function was given, simulate a module:init structure
     */
    if (typeof item === 'function') {
        return new Plugin().mergeDeep({
            module: {
                init: item
            }
        });
    }

    /**
     * If an object is given, with a module property that's a string,
     * use that string to resolve the module with default options
     * and then merge from the top level. This is
     * to ensure things such as options/active state are not missed
     * eg: plugins: [{module: './lib/plugin', options: {name: 'shane}}}]
     */
    if (isString(item.get('module'))) {
        return resolvePluginFromString(item.get('module')).mergeDeep(item.delete('module'));
    }

    if (Imm.Map.isMap(item.get('module'))) {
        return new Plugin().mergeDeep(item);
    }

    /**
     * Final use-case is a plain object, with a module property
     * that is an object. This is to allow plugins directly in the
     * configuration, skipping the node require lookup
     */
    return new Plugin().mergeDeep({module: item});
}
开发者ID:b-cuts,项目名称:browser-sync-core,代码行数:46,代码来源:plugins.ts

示例9: handleServerOption

export function handleServerOption(incoming: BsTempOptions): TransformResult {
    const value = incoming.get('server');
    if (value === false) {
        return [incoming, []];
    }

    // server: true
    if (value === true) {
        const obj: IServerOption = {
            baseDir: ["./"]
        };
        return [incoming.set('server', fromJS(obj)), []];
    }

    // server: "./app"
    if (typeof value === "string") {
        const obj: IServerOption = {
            baseDir: [value]
        };
        return [incoming.set('server', fromJS(obj)), []];
    }

    if (List.isList(value)) {
        const obj: IServerOption = {
            baseDir: value
        };
        return [incoming.set('server', fromJS(obj)), []];
    }

    if (Map.isMap(value)) {
        const dirs = List([])
            .concat(value.get("baseDir", "./"))
            .filter(Boolean);

        const merged = value.merge({baseDir: dirs});

        return [incoming.set('server', merged), []];
    }

    return [incoming, []];
}
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:41,代码来源:handleServerOption.ts

示例10: select

 private select(where: WhereCondition): immutable.Set<number> {
   if (immutable.Map.isMap(where)) {
     // TODO: maybe do not allow?
     where = where.toJS();
   }
   // Return immutable set with defined indexes the elts of @_records that
   // satisfy the where condition.
   const n: number = len(where);
   let result: immutable.Set<number> | undefined = undefined;
   for (let field in where) {
     const value = where[field];
     const index = this.indexes.get(field);
     if (index == null) {
       throw Error(`field '${field}' must be a primary key`);
     }
     const v: immutable.Set<number> | undefined = index.get(to_key(value));
     // v may be undefined here
     if (v == null) {
       return immutable.Set(); // no matches for this field - done
     }
     if (n === 1) {
       // no need to do further intersection
       return v;
     }
     if (result != null) {
       // intersect with what we've found so far via indexes.
       result = result.intersect(v);
     } else {
       result = v;
     }
   }
   if (result == null) {
     // where condition must have been empty -- matches everything
     return this.everything;
   } else {
     return result;
   }
 }
开发者ID:DrXyzzy,项目名称:smc,代码行数:38,代码来源:doc.ts


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