本文整理汇总了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();
}
示例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(
示例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 );
}
示例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);
}
示例5: parseQueryString
.map<NextInstruction>(set => {
return {
locationChange: change,
routeConfigs: set.routes,
queryParams: parseQueryString(queryString),
routeParams: set.params
};
});
示例6: parseQueryString
.map<NextRoute>(set => {
return {
url: location$.path(),
routes: set.routes,
query: parseQueryString(queryString),
params: set.params
};
});
示例7: isDebugMode
export function isDebugMode() {
if (typeof window !== 'undefined') {
const queryObject = parse(window.location.search)
return queryObject.debug !== undefined
} else {
return false
}
}
示例8: isExperimentalApiMode
export function isExperimentalApiMode() {
if (typeof window !== 'undefined') {
const queryObject = parse(window.location.search)
return queryObject.experimental !== undefined
} else {
return false
}
}
示例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)
}
}
示例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']
};
}
示例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]);
});
});
}
示例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;
});
示例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 };
};
示例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;
}
示例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))
}
}