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

TypeScript qs.parse函数代码示例

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

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



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


示例16: pickBy

export const updateQueryParams = (updatedQueryParams: object): void => {
  const currentQueryString = window.location.search
  const newQueryParams = pickBy(
    {
      ...qs.parse(currentQueryString, {ignoreQueryPrefix: true}),
      ...updatedQueryParams,
    },
    v => !!v
  )

  const newQueryString = qs.stringify(newQueryParams)

  browserHistory.replace(`${window.location.pathname}?${newQueryString}`)
}
开发者ID:influxdata,项目名称:influxdb,代码行数:14,代码来源:queryParams.ts


示例17: function

const setupToken = function (successCallback: SuccessCallback, errorCallback: () => void): void {
    let query = qs.parse(window.location.search, {
        ignoreQueryPrefix: true
    });
    let token = query[TOKEN_URL_KEY];

    if (token) {
        setToken(token);
        delete query[TOKEN_URL_KEY];
        let searchWithoutToken = Object.keys(query).length ? qs.stringify(query, { addQueryPrefix: true }) : '';
        successCallback(token, searchWithoutToken);
    } else if (getToken() === null) {
        errorCallback();
    }
};
开发者ID:Ed-wu,项目名称:basket-mobile,代码行数:15,代码来源:token.ts


示例18: handleQs

export default function handleQs(url: string, query: {[key: string]: any}): string {
  const [start, part2] = url.split('?');
  let qs = (part2 || '').split('#')[0];
  const end = part2 && part2.split('#').length > 1 ? '#' + part2.split('#')[1] : '';

  const baseQs = parse(qs);
  for (var i in query) {
    baseQs[i] = query[i];
  }
  qs = stringify(baseQs);
  if (qs !== '') {
    qs = '?' + qs;
  }
  return start + qs + end;
}
开发者ID:then,项目名称:then-request,代码行数:15,代码来源:handle-qs.ts


示例19: stripPrefix

export const updateQueryParams = (updatedQueryParams: object): RouterAction => {
  const {search, pathname} = window.location
  const strippedPathname = stripPrefix(pathname)

  const newQueryParams = _.pickBy(
    {
      ...qs.parse(search, {ignoreQueryPrefix: true}),
      ...updatedQueryParams,
    },
    v => !!v
  )

  const newSearch = qs.stringify(newQueryParams)
  const newLocation = {pathname: strippedPathname, search: `?${newSearch}`}

  return replace(newLocation)
}
开发者ID:influxdata,项目名称:influxdb,代码行数:17,代码来源:ranges.ts


示例20:

 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,代码行数:19,代码来源:login.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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