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


TypeScript qs.parse函数代码示例

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


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

示例1:

        header.split(",").map(link => {
            link = link.trim();

            // Needs to fit our expected format.
            const parts = link.match(/<([0-9a-zA-Z$\-_.+!*'(),:/?=&%#]+)>;\s+rel="(next|prev)"/);
            if (!parts) {
                return;
            }

            // Extract the relevant bits.
            const [fullMatch, url, rel] = parts;

            // Confirm we have a query string.
            const search = url.match(/\?([^#]+)/);
            if (!search || !search[1]) {
                return;
            }

            // Break out the query string into individual parameters.
            const searchParameters = qs.parse(search[1]);

            // Grab the next or prev page number.
            if (searchParameters[param]) {
                result[rel] = searchParameters[param];
            }

            // Grab the limit from the current link.
            if (limitParam && searchParameters[limitParam]) {
                result.limit = searchParameters[param];
            }
        });
开发者ID:vanilla,项目名称:vanilla,代码行数:31,代码来源:SimplePagerModel.ts

示例2: it

 it('contains a subject', () => {
   const queryString = parse(mailto.split('?')[1]);
   expect(queryString).toHaveProperty(
     'Subject',
     'Cloud Manager User Feedback'
   );
 });
开发者ID:linode,项目名称:manager,代码行数:7,代码来源:createMailto.test.ts

示例3: loginValidate

export default function loginValidate(location, history, navigation) {
  const query = window.location.search.replace(/^\?/, '');
  const xTicket = qs.parse(query)['ticket'];
  window.uw.request({
    url: '/unified/auth/doAuth',
    needLogin: false,
    headers: {
      'x-ticket': xTicket,
    },
    success: ({ code, data }) => {
      if (code === '4000') {
        if (navigation) {
          window.location.href = `${data.loginUrl}${window.location.href}`;
        } else {
          window.top.location.href = `${data.loginUrl}${window.top.location.href}`;
        }
      } else {
        window.uw.event.emit('@@auth_success');
        const userName = window.uw.cookie.get('userName');
        const isAdmin = window.uw.cookie.get('isAdmin');
        const userId = window.uw.cookie.get('userId');
        window.uw.storage.set('global.user', { userName, isAdmin: isAdmin === 'true' ? true : false, userId });
        const { pathname, search } = location;
        let queryWithoutTicket = _.omit(qs.parse(search.replace(/^\?/, '')), ['ticket', 'loginParam', 'lengh', 'length', 'sessionKey']);
        queryWithoutTicket = qs.stringify(queryWithoutTicket);
        history.replace(`${pathname}${queryWithoutTicket === '' ? '' : `?${queryWithoutTicket}`}`);
      }
    },
  });
}
开发者ID:lixuefeng123,项目名称:Metis,代码行数:30,代码来源:login.ts

示例4: getPartialExecutionResult

    /**
     * Get one page of Result from Execution (with requested limit and offset)
     *
     * @method getPartialExecutionResult
     * @param {string} executionResultUri
     * @param {number[]} limit - limit for each dimension
     * @param {number[]} offset - offset for each dimension
     *
     * @returns {Promise<Execution.IExecutionResult | null>}
     *  Promise with `executionResult` or `null` (null means empty response - HTTP 204)
     *  See https://github.com/gooddata/gooddata-typings/blob/v2.1.0/src/Execution.ts#L88
     */
    public getPartialExecutionResult(executionResultUri: string, limit: number[], offset: number[])
        : Promise<Execution.IExecutionResult | null> {
        const executionResultUriQueryPart = getExecutionResultUriQueryPart(executionResultUri);
        const numOfDimensions = Number(qs.parse(executionResultUriQueryPart).dimensions);
        validateNumOfDimensions(numOfDimensions);

        return this.getPage(executionResultUri, limit, offset);
    }
开发者ID:gooddata,项目名称:gooddata-js,代码行数:20,代码来源:execute-afm.ts

示例5: deriveViewport

export function deriveViewport(hash: string): Viewport {
  const parsed = qs.parse(hash);
  return {
    ...viewportInit,
    latitude: parseFloat(parsed.latitude) || viewportInit.latitude,
    longitude: parseFloat(parsed.longitude) || viewportInit.longitude,
    zoom: parseFloat(parsed.zoom) || viewportInit.zoom,
  };
}
开发者ID:cmc333333,项目名称:mapusaurus,代码行数:9,代码来源:initial-state.ts

示例6: function

onRequest = function (request, reply) {

    const uri = request.raw.req.url;
    const parsed = Url.parse(uri, false);
    parsed.query = Qs.parse(parsed.query);
    request.setUrl(parsed);

    return reply.continue();
};
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:9,代码来源:set-url.ts

示例7: return

  return (req, res, next) => {
    if (!req.getQuery()) {
      req.query = {};
      return next();
    }

    req.query = qs.parse(req.getQuery(), { allowDots: true });
    return next();
  };
开发者ID:himulawang,项目名称:island,代码行数:9,代码来源:restify-query-parser.ts

示例8: function

export const createHistory = function(){
  return useQueries(createHistoryFn)({
    stringifyQuery(ob){
      return qs.stringify(ob, {encode:true})
    },
    parseQueryString(str){
      return qs.parse(str)
    }
  })
}
开发者ID:Baltox,项目名称:searchkit,代码行数:10,代码来源:history.ts

示例9: replaceLimitAndOffsetInUri

export function replaceLimitAndOffsetInUri(oldUri: string, limit: number[], offset: number[]): string {
    const [uriPart, queryPart] = oldUri.split(/\?(.+)/);
    const query = {
        ...qs.parse(queryPart),
        limit: limit.join(','),
        offset: offset.join(',')
    };

    return uriPart + qs.stringify(query, { addQueryPrefix: true });
}
开发者ID:gooddata,项目名称:gooddata-js,代码行数:10,代码来源:execute-afm.ts

示例10: getState

export const updateTimeRangeFromQueryParams = (dashboardID: string) => (
  dispatch: Dispatch<Action>,
  getState
): void => {
  const {ranges} = getState()
  const queryParams = qs.parse(window.location.search, {
    ignoreQueryPrefix: true,
  })

  const timeRangeFromQueries = {
    lower: queryParams.lower,
    upper: queryParams.upper,
  }

  const zoomedTimeRangeFromQueries = {
    lower: queryParams.zoomedLower,
    upper: queryParams.zoomedUpper,
  }

  let validatedTimeRange = validTimeRange(timeRangeFromQueries)

  if (!validatedTimeRange.lower) {
    const dashboardTimeRange = ranges.find(r => r.dashboardID === dashboardID)

    validatedTimeRange = dashboardTimeRange || DEFAULT_TIME_RANGE

    if (timeRangeFromQueries.lower || timeRangeFromQueries.upper) {
      dispatch(notify(copy.invalidTimeRangeValueInURLQuery()))
    }
  }

  dispatch(setDashTimeV1(dashboardID, validatedTimeRange))

  const validatedZoomedTimeRange = validAbsoluteTimeRange(
    zoomedTimeRangeFromQueries
  )

  if (
    !validatedZoomedTimeRange.lower &&
    (queryParams.zoomedLower || queryParams.zoomedUpper)
  ) {
    dispatch(notify(copy.invalidZoomedTimeRangeValueInURLQuery()))
  }

  dispatch(setZoomedTimeRange(validatedZoomedTimeRange))

  const updatedQueryParams = {
    lower: validatedTimeRange.lower,
    upper: validatedTimeRange.upper,
    zoomedLower: validatedZoomedTimeRange.lower,
    zoomedUpper: validatedZoomedTimeRange.upper,
  }

  dispatch(updateQueryParams(updatedQueryParams))
}
开发者ID:influxdata,项目名称:influxdb,代码行数:55,代码来源:ranges.ts

示例11: dispatch

) => (action: Action) => {
  dispatch(action)

  const urlQueryParams = qs.parse(window.location.search, {
    ignoreQueryPrefix: true,
  })

  if (urlQueryParams.present === 'true') {
    dispatch(enablePresentationMode())
  }
}
开发者ID:influxdata,项目名称:influxdb,代码行数:11,代码来源:queryStringConfig.ts

示例12: getExecutionResult

    /**
     * Get whole ExecutionResult
     *
     * @method getExecutionResult
     * @param {string} executionResultUri
     *
     * @returns {Promise<Execution.IExecutionResult | null>}
     *  Promise with `executionResult` or `null` (null means empty response - HTTP 204)
     *  See https://github.com/gooddata/gooddata-typings/blob/v2.1.0/src/Execution.ts#L88
     */
    public getExecutionResult(executionResultUri: string)
        : Promise<Execution.IExecutionResult | null> {
        const executionResultUriQueryPart = getExecutionResultUriQueryPart(executionResultUri);
        const numOfDimensions = Number(qs.parse(executionResultUriQueryPart).dimensions);
        validateNumOfDimensions(numOfDimensions);

        const limit = Array(numOfDimensions).fill(DEFAULT_LIMIT);
        const offset = Array(numOfDimensions).fill(0);

        return this.getAllPages(executionResultUri, limit, offset);
    }
开发者ID:gooddata,项目名称:gooddata-js,代码行数:21,代码来源:execute-afm.ts

示例13: return

    return (ctx: any, next: any) => {

        if (ctx.request.querystring && ctx.request.querystring.length > 0) {
            ctx.request.query = qs.parse(ctx.request.querystring);
        } else {

            ctx.request.query = {};
        }

        ctx.params = Object.assign({}, ctx.request.query, ctx.request.body);
        return next();
    };
开发者ID:zcg331793187,项目名称:DownloadYouLike,代码行数:12,代码来源:queryParse.ts

示例14:

export const updateSearch = (
  history: History,
  updates: { readonly [id: string]: any },
) => {
  history.push({
    pathname: history.location.pathname,
    search: qs.stringify({
      ...qs.parse(history.location.search),
      ...updates,
    }),
  });
};
开发者ID:mmerfort,项目名称:puppetexplorer,代码行数:12,代码来源:util.ts

示例15: deriveMapbox

export function deriveMapbox(hash: string, windowConfig): Mapbox {
  const { token } = windowConfig;
  const parsed = qs.parse(hash, { depth: 0, skipNulls: true });
  const choropleth = parsed.choropleth ?
    `${parsed.choropleth}` : mapboxInit.choropleth;
  const features = parsed.features ?
    toSelected(parsed.features) : mapboxInit.features;
  return {
    ...mapboxInit,
    choropleth,
    features,
    token,
  };
}
开发者ID:cmc333333,项目名称:mapusaurus,代码行数:14,代码来源:initial-state.ts


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