本文整理汇总了TypeScript中src/UrlSearchParams.getAll函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getAll函数的具体用法?TypeScript getAll怎么用?TypeScript getAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getAll函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: checkParams
construct: (function () {
function checkParams(params: UrlSearchParams) {
assert.deepEqual(params.getAll('foo'), [ 'bar', 'baz' ]);
assert.deepEqual(params.getAll('bar'), [ 'foo' ]);
assert.deepEqual(params.getAll('baz'), [ '' ]);
}
return {
empty() {
// Empty UrlSearchParams should have no properties
const params = new UrlSearchParams();
assert.isNull(params.get('foo'));
},
// Next three tests should generate 'params' objects with same contents
object() {
const params = new UrlSearchParams({ foo: [ 'bar', 'baz' ], bar: 'foo', baz: null });
checkParams(params);
},
string() {
let params = new UrlSearchParams('foo=bar&foo=baz&bar=foo&baz');
checkParams(params);
// Assignments after the first will be ignored
params = new UrlSearchParams('foo=bar=baz');
assert.deepEqual(params.getAll('foo'), [ 'bar' ]);
// Handle empty keys
params = new UrlSearchParams('=foo&');
assert.deepEqual(params.getAll(''), [ 'foo', '' ]);
},
UrlSearchParams() {
const params1 = new UrlSearchParams({ foo: [ 'bar', 'baz' ], bar: 'foo', baz: null });
const params = new UrlSearchParams(params1);
checkParams(params);
}
}
})(),
示例2: UrlSearchParams
},
UrlSearchParams() {
const params1 = new UrlSearchParams({ foo: [ 'bar', 'baz' ], bar: 'foo', baz: null });
const params = new UrlSearchParams(params1);
checkParams(params);
}
}
})(),
'#append': {
'new key'() {
// Appending with a new key is the same as 'set'
const params = new UrlSearchParams();
params.append('foo', 'bar');
assert.deepEqual(params.getAll('foo'), [ 'bar' ]);
},
'existing key'() {
const params = new UrlSearchParams({ foo: 'bar' });
params.append('foo', 'baz');
assert.deepEqual(params.getAll('foo'), [ 'bar', 'baz' ]);
}
},
'#delete'() {
const params = new UrlSearchParams({ foo: 'bar' });
params.delete('foo');
assert.isNull(params.get('foo'));
},