當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。