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

TypeScript query-string.parse函数代码示例

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

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



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

示例1: getFileServerRelativeUrl

function getFileServerRelativeUrl(): JQueryPromise<any> {
    let deferred: JQueryDeferred<any> = $.Deferred();

    let parsed: any = parse(location.search);

    return deferred.promise();
}
开发者ID:Frederick-S,项目名称:SharePoint-Add-in-Move-File,代码行数:7,代码来源:index.ts


示例2: Prompt

 Prompt('Save Serverspec', "filename").then((fname) => {
   const s = new Serverspec();
   const infra_id_str: string = qs.parse(location.search).infrastructure_id;
   const infra_id: number     = infra_id_str ? parseInt(infra_id_str) : null;
   const code = 'require "serverspec_helper"\n\n' + app.rubyCode;
   return s.create(fname, code, infra_id);
 }).then(
开发者ID:pocke,项目名称:skyhopper,代码行数:7,代码来源:serverspec-gen.ts


示例3: gotoQueryParams

	// I navigate to the current URL with the given name-value pairs in the query-string.
	// This method is designed to leave all other query-string parameters in place.
	public gotoQueryParams( delta: { [key: string]: any } ) : void {

		var parts = this.router.path().split( "?" );
		var pathString = parts.shift();
		var queryString = parts.shift();
		var updatedQueryParams = parse( queryString );

		for ( var key in delta ) {

			if ( delta[ key ] === null ) {

				delete( updatedQueryParams[ key ] );

			} else {

				updatedQueryParams[ key ] = delta[ key ];

			}

		}


		this.router.go( pathString, updatedQueryParams );

	}
开发者ID:bennadel,项目名称:JavaScript-Demos,代码行数:27,代码来源:router-utils.ts


示例4: defaultGroups

export function defaultGroups(facultyMap: FacultyDepartments, query: string = ''): FilterGroups {
  const params = qs.parse(query);

  const faculties = Object.keys(facultyMap);
  const departments = flatten(values(facultyMap));

  const groups: FilterGroups = {
    [SEMESTER]: new FilterGroup(
      SEMESTER,
      'Available In',
      map(config.semesterNames, (name, semesterStr) => {
        const semester = parseInt(semesterStr, 10);
        return new Filter(
          semesterStr,
          name,
          (module) => !!module.semesterData.find((semData) => semData.semester === semester),
        );
      }),
    ),

    [LEVELS]: new FilterGroup(
      LEVELS,
      'Levels',
      moduleLevels.map((level) => new LevelFilter(level)),
    ),

    [MODULE_CREDITS]: new FilterGroup(MODULE_CREDITS, 'Module Credit', [
      new Filter('0', '0-3 MC', (module) => parseFloat(module.moduleCredit) <= 3),
      new Filter('4', '4 MC', (module) => module.moduleCredit === '4'),
      new Filter('5', '5-8 MC', (module) => {
        const credits = parseFloat(module.moduleCredit);
        return credits > 4 && credits <= 8;
      }),
      new Filter('8', 'More than 8 MC', (module) => parseInt(module.moduleCredit, 10) > 8),
    ]),

    [DEPARTMENT]: makeDepartmentFilterGroup(departments),

    [FACULTY]: makeFacultyFilterGroup(faculties),

    [EXAMS]: makeExamFilter(),

    [ATTRIBUTES]: new FilterGroup(ATTRIBUTES, 'Others', [
      makeAttributeFilter('su'),
      makeAttributeFilter('grsu'),
      makeAttributeFilter('ssgf'),
      makeAttributeFilter('sfs'),
      makeAttributeFilter('lab'),
      makeAttributeFilter('ism'),
    ]),
  };

  // Search query group
  if (params[SEARCH_QUERY_KEY]) {
    groups[SEARCH_QUERY_KEY] = createSearchFilter(params[SEARCH_QUERY_KEY]);
  }

  return updateGroups(groups, query);
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:59,代码来源:moduleFilters.ts


示例5: parseQueryString

 .map<NextInstruction>(set => {
   return {
     locationChange: change,
     routeConfigs: set.routes,
     queryParams: parseQueryString(queryString),
     routeParams: set.params
   };
 });
开发者ID:nathasm,项目名称:router,代码行数:8,代码来源:router-instruction.ts


示例6: parseQueryString

 .map<NextRoute>(set => {
   return {
     url: location$.path(),
     routes: set.routes,
     query: parseQueryString(queryString),
     params: set.params
   };
 });
开发者ID:fxck,项目名称:router,代码行数:8,代码来源:route-set.ts


示例7: isDebugMode

export function isDebugMode() {
	if (typeof window !== 'undefined') {
		const queryObject = parse(window.location.search)
		return queryObject.debug !== undefined
	} else {
		return false
	}
}
开发者ID:gaearon,项目名称:react-dnd,代码行数:8,代码来源:isDebugMode.ts


示例8: isExperimentalApiMode

export function isExperimentalApiMode() {
	if (typeof window !== 'undefined') {
		const queryObject = parse(window.location.search)
		return queryObject.experimental !== undefined
	} else {
		return false
	}
}
开发者ID:gaearon,项目名称:react-dnd,代码行数:8,代码来源:renderHtmlAst.ts


示例9: getPolls

const mapState = (state: RootState, ownProps: Props): MapStateProps => {
  const queryParams: QueryParams = queryString.parse(ownProps.location.search)
  return {
    type: ownProps.type || queryParams.type || 'all',
    status: ownProps.status || queryParams.status || 'all',
    page: +queryParams.page || 1,
    polls: getPolls(state),
    totalRows: getTotal(state)
  }
}
开发者ID:decentraland,项目名称:agora,代码行数:10,代码来源:PollsTable.container.ts


示例10: authCallback

export function authCallback(urlString: string): types.AuthenticateResponse {
    const paramsString = urlString.slice(urlString.indexOf('?') + 1);
    const params = querystring.parse(paramsString);

    return {
        code: params['code'],
        state: params['state'],
        error: params['error']
    };
}
开发者ID:emonkak,项目名称:feedpon,代码行数:10,代码来源:api.ts


示例11: updateGroups

export function updateGroups(groups: FilterGroups, query: string): FilterGroups {
  const params = qs.parse(query);

  return produce(groups, (draft) => {
    each(draft, (group) => {
      const currentQuery = group.toQueryString();
      if (currentQuery === params[group.id] || (!params[group.id] && !currentQuery)) return;
      draft[group.id] = group.fromQueryString(params[group.id]);
    });
  });
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:11,代码来源:moduleFilters.ts


示例12: Error

 return TMAuth.httpClient.get<string>(accessTokenUri, header).then(rt => {         
     let response: TMAuthRequestTokenResponse = {};
     let qsParts = qs.parse(rt.Response);
     response.oauth_token = qsParts["oauth_token"];
     response.oauth_token_secret = qsParts["oauth_token_secret"];
     if (qsParts.oauth_token === undefined || 
         qsParts.oauth_token_secret === undefined) {
         throw new Error(rt.Response);
     }
     return response;
 });
开发者ID:wizact,项目名称:tmj-cli,代码行数:11,代码来源:TMAuth.ts


示例13: each

export const parseQueryString = (
  location: LocationState
): { [key: string]: string } => {
  const query = {
    ...parseQs(location.search.substr(1))
  };
  each(query, (value, key) => {
    if (Array.isArray(value)) {
      query[key] = value[0];
    }
  });
  return query as { [key: string]: string };
};
开发者ID:p2p-ms,项目名称:front,代码行数:13,代码来源:utils.ts


示例14: parse

  parse(url: string) {
    const queryParams: any = queryString.parse(parseUri(url).query);
    const queryFromUrl = new Query(queryParams[this.urlConfig.queryParam] || '')
      .withConfiguration(this.config, CONFIGURATION_MASK);

    if (queryParams.refinements) {
      const refinements = JSON.parse(queryParams.refinements);
      if (refinements.length > 0) {
        queryFromUrl.withSelectedRefinements(...refinements);
      }
    }

    return queryFromUrl;
  }
开发者ID:groupby,项目名称:searchandiser-ui,代码行数:14,代码来源:simple-beautifier.ts


示例15: dispatch

const mapDispatch = (dispatch: any, ownProps: any): MapDispatchProps => {
  const queryParams: QueryParams = queryString.parse(ownProps.location.search)
  const type = ownProps.type || queryParams.type || 'all'
  const status = ownProps.status || queryParams.status || 'all'
  return {
    onPageChange: (page: number) =>
      dispatch(navigateTo(locations.pollsTable(page, type, status))),
    onStatusChange: (status: FilterStatus) =>
      dispatch(navigateTo(locations.pollsTable(1, type, status))),
    onFetchPolls: (pagination: PollsRequestFilters) =>
      dispatch(fetchPollsRequest(pagination)),
    onNavigate: (location: string) => dispatch(navigateTo(location))
  }
}
开发者ID:decentraland,项目名称:agora,代码行数:14,代码来源:PollsTable.container.ts


示例16: parse

export const prepareNodeParams: TPrepareNodeParams = type => ({
  location: { search },
  match: { params },
}) => {
  const q = parse(search);
  const qq = {
    ...q,
    filters: parseFilterParam(q.filters, null),
  };

  return {
    id: btoa(`${type}:${params.id}`),
    ...qq,
  };
};
开发者ID:NCI-GDC,项目名称:portal-ui,代码行数:15,代码来源:index.ts


示例17:

                ({method, pathRegex, queryParamsObject, bodyRestriction = {}}: MockedCall) => {
                    if (method !== this.req.method) {
                        return false;
                    }

                    if (!new RegExp(pathRegex).test(this.url)) {
                        return false;
                    }

                    const contentTypeIsApplicationJson = this.request.header['content-type'] === 'application/json';

                    if (queryParamsObject) {
                        const splitUrl = this.url.split('?');

                        if (splitUrl.length < 2) {
                            return false;
                        }
                        const queryParamsOnUrl = queryString.parse(splitUrl[1]);

                        if (!deepEquals(queryParamsOnUrl, queryParamsObject)) {
                            return false;
                        }
                    }
                    if (bodyRestriction.regex) {
                        const requestBodyAsString = contentTypeIsApplicationJson
                            ? JSON.stringify(this.request.body)
                            : this.request.body;

                        if (!new RegExp(bodyRestriction.regex).test(requestBodyAsString)) {
                            return false;
                        }
                    }
                    if (
                        bodyRestriction.minimalObject &&
                        (!contentTypeIsApplicationJson || !isSubset(this.request.body, bodyRestriction.minimalObject))
                    ) {
                        return false;
                    }

                    if (
                        bodyRestriction.object &&
                        (!contentTypeIsApplicationJson || !deepEquals(this.request.body, bodyRestriction.object))
                    ) {
                        return false;
                    }

                    return true;
                }
开发者ID:Soluto,项目名称:simple-fake-server,代码行数:48,代码来源:FakeServer.ts


示例18: loadQueryString

 public loadQueryString(qs:string) {
   let params = querystring.parse(location.search);
   let paramNames = Object.keys(params);
   let keys = Object.keys(this.tracks);
   for (let k of paramNames) {
     if (keys.indexOf(k) === -1) {
       keys.push(k);
     }
   }
   for (let key of keys) {
     this.tracks[key] =
       typeof params[key] === "string"
         ? params[key].split(/,/)
         : [];
     console.info("loaded tracks",this.tracks, "from", qs);
   }
 }
开发者ID:c9s,项目名称:qama,代码行数:17,代码来源:EntryStore.ts


示例19: constructor

  constructor(window) {
    this._window = window;
    this._parsedQs = QS.parse(window.location.search);

    // We need to check whether we are inside a iframe or not.
    // This is used by here and as well as in the UI
    this._iframeMode = Boolean(this._parsedQs.dataId);

    // We need to create a unique Id for each page. We need to communicate
    // using this id as a namespace. Otherwise, each every iframe will get the
    // data.
    //  We create a new UUID if this is main page. Then, this is used by UI to
    //  create queryString param when creating the iframe.
    //  If we are in the iframe, we'll get it from the queryString.
    this._dataId = this._iframeMode ? this._parsedQs.dataId : UUID.v4();
    this._data = {
      iframeMode: this._iframeMode,
      dataId: this._dataId,
    };

    this._handlers = [];
  }
开发者ID:tycho01,项目名称:react-storybook,代码行数:22,代码来源:synced_store.ts


示例20: State

import {
  width,
  height,
} from './constants';

import State, {Layer} from './state';
import render from './render';

// Create canvas
const canvas = document.querySelector('#canvas') as HTMLCanvasElement;
canvas.width = width;
canvas.height = height;
const ctx = canvas.getContext('2d');

// Parse opts
const query = qs.parse(location.search);

// Create state
const state = new State({
  initialTransitionIndex: query.transition ? parseInt(query.transition) : null,
});

// Run loop
let time = Date.now();
function runLoop() {
  const now = Date.now();
  const dt = now - time;
  time = now;

  state.update(dt, now);
  render(ctx, state);
开发者ID:thomasboyt,项目名称:echoes-viz,代码行数:31,代码来源:entry.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript query-string.stringify函数代码示例发布时间:2022-05-25
下一篇:
TypeScript querablep.default函数代码示例发布时间: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