當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript query-string.parse函數代碼示例

本文整理匯總了TypeScript中query-string.parse函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript parse函數的具體用法?TypeScript parse怎麽用?TypeScript parse使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了parse函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的query-string.parse函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。