本文整理匯總了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))
}
}