本文整理匯總了TypeScript中Immutable.List函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript List函數的具體用法?TypeScript List怎麽用?TypeScript List使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了List函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getAvailableAlignedCorpora
getAvailableAlignedCorpora():Immutable.List<Kontext.AttrItem> {
return Immutable.List<Kontext.AttrItem>();
}
示例2: getUsedAttributes
getUsedAttributes():Array<string> {
return this.selectionSteps.reduce((red:Immutable.List<any>, val:SelectionStep) => {
return red.concat(val.attributes);
}, Immutable.List([])).toArray();
}
示例3: reducer
export function reducer(state: State = initialState, action: project.Actions): State {
switch(action.type) {
case project.PROJECT_LOAD_SUCCESS: {
/* Handle new project:
* For `new project` there is no defined video, therefore
* the video data from the previous state is used.
*/
const prevDuration = state.getIn(['meta', 'timeline', 'duration'])
const prevVideoMeta = state.getIn(['meta', 'video'])
const prevVideoBlob = state.get('videoBlob', null)
const {meta: {id, timeline, video:videoMeta}, video} = action.payload
if(videoMeta === null) {
timeline.duration = prevDuration
}
if(videoMeta && videoMeta.type === VIDEO_TYPE_URL) {
videoMeta.url = new URL(videoMeta.url)
}
// Create immutable representation
return new ProjectRecordFactory({
videoBlob: video === null ? prevVideoBlob: video,
player: state.get('player', new ProjectPlayerStateRecordFactory()),
meta: ProjectMetaRecordFactory({
id,
video: videoMeta === null ? prevVideoMeta : (videoMeta.type === VIDEO_TYPE_BLOB ? BlobVideoRecordFactory(videoMeta) : UrlVideoRecordFactory(videoMeta)),
timeline: TimelineRecordFactory({
...timeline,
tracks: List(timeline.tracks.map((track: any) => {
const {title: trackTitle} = track.fields
return new TrackRecordFactory({
...track,
fields: TrackFieldsRecordFactory({title: trackTitle}),
annotationStacks: List(track.annotationStacks.map((annotations: any) => {
return List(annotations.map((annotation: any) => {
const {description} = annotation.fields
return new AnnotationRecordFactory({
...annotation,
fields: new AnnotationFieldsRecordFactory({description}),
})
}))
}))
})
}))
})
})
})
}
case project.PROJECT_IMPORT_VIDEO_SUCCESS: {
const payload = action.payload
switch(payload.type) {
case VIDEO_TYPE_BLOB: {
const blobVideo = payload.data as File|Blob
return state
.set('videoBlob', blobVideo)
.setIn(['meta', 'video'], BlobVideoRecordFactory({type: VIDEO_TYPE_BLOB}))
}
case VIDEO_TYPE_URL: {
const videoMeta = {
type: VIDEO_TYPE_URL,
source: payload.source as VideoUrlSource,
url: payload.data as URL
}
return state
.set('videoBlob', null)
.setIn(['meta', 'video'], UrlVideoRecordFactory(videoMeta))
}
}
return state
}
case project.PROJECT_SET_TIMELINE_DURATION: {
return state.setIn(['meta', 'timeline', 'duration'], action.payload.duration)
}
case project.PROJECT_ADD_ANNOTATION: {
const {trackIndex, annotationStackIndex, annotation, source} = action.payload
let placedTrackIndex = trackIndex
let placedAnnotation = annotation
if(source === 'toolbar') {
const tracks = state.getIn(['meta', 'timeline', 'tracks']) as List<Record<Track>>
placedTrackIndex = tracks.findIndex(track => track.get('isActive', false))
placedAnnotation = annotation.set('utc_timestamp', state.getIn(['player', 'currentTime']))
}
const annotationStacks = state.getIn(['meta', 'timeline', 'tracks', placedTrackIndex, 'annotationStacks'])
const newId = nextAnnotationId(state.getIn(['meta', 'timeline']))
const newAnnotation = placedAnnotation.set('id', newId)
const timelineDuration = state.getIn(['meta', 'timeline', 'duration'])
const stacksWithEmbedded = embedAnnotations(timelineDuration, annotationStacks, annotationStackIndex, List([newAnnotation]), List([]))
return state.setIn(['meta', 'timeline', 'tracks', placedTrackIndex, 'annotationStacks'], stacksWithEmbedded)
}
case project.PROJECT_UPDATE_ANNOTATION: {
const {trackIndex, annotationIndex, annotationStackIndex, annotation} = action.payload
const path = ['meta', 'timeline', 'tracks', trackIndex, 'annotationStacks']
const annotationStacks: List<List<Record<Annotation>>> = state.getIn(path)
const prevAnnotation: Record<Annotation> = annotationStacks.getIn([annotationStackIndex, annotationIndex])
const timelineDuration = state.getIn(['meta', 'timeline', 'duration'])
//.........這裏部分代碼省略.........
示例4: describe
describe('LinkViewConfig', () => {
var dataSourceJS = {
name: 'twitter',
title: 'Twitter',
engine: 'druid',
source: 'twitter',
introspection: 'none',
dimensions: [
{
expression: {
name: 'time',
op: 'ref'
},
kind: 'time',
name: 'time'
},
{
expression: '$statusCode',
kind: 'string',
name: 'statusCode'
}
],
measures: [
{
name: 'count',
expression: '$main.count()'
},
{
name: 'uniqueIp',
expression: '$main.countDistinct($ip)'
}
],
timeAttribute: 'time',
defaultTimezone: 'Etc/UTC',
defaultFilter: { op: 'literal', value: true },
defaultDuration: 'P3D',
defaultSortMeasure: 'count',
refreshRule: {
rule: "fixed",
time: new Date('2015-09-13T00:00:00Z')
}
};
var dataSources = List([DataSource.fromJS(dataSourceJS)]);
var visualizations: any = List([
{
id: 'vis1',
title: 'vis1',
handleCircumstance(): any {
return { 'isAutomatic': () => false };
}
}
]);
var context = { dataSources, visualizations };
it('is an immutable class', () => {
testImmutableClass(LinkViewConfig, [
{
title: 'The Links Will Rise Again!',
linkItems: [
{
name: 'test1',
title: 'Test One',
description: 'I like testing',
group: 'Tests',
dataSource: 'twitter',
essence: {
visualization: 'vis1',
timezone: 'Etc/UTC',
filter: {
op: "literal",
value: true
},
pinnedDimensions: ['statusCode'],
selectedMeasures: ['count'],
splits: []
}
}
]
}
], { context });
});
});
示例5: Record
// limitations under the License.
import { List, Map, Record } from "immutable";
import { BehaviorSubject } from "rxjs";
import { Origin } from "./records/Origin";
import { Package } from "./records/Package";
export default Record({
app: Record({
name: "Habitat",
currentYear: new Date().getFullYear(),
})(),
gitHub: Record({
authState: undefined,
authToken: undefined,
orgs: List(),
repos: List(),
selectedOrg: undefined,
username: undefined,
ui: Record({
orgs: Record({
loading: false,
})(),
repos: Record({
loading: false,
})()
})()
})(),
builds: Record({
visible: List(),
selected: Record({
示例6: Range
check.it('takes the first n from a list', [gen.int, gen.posInt], (len, num) => {
var a = Range(0, len).toArray();
var v = List(a);
expect(v.take(num).toArray()).toEqual(a.slice(0, num));
})
示例7: it
it('works in simple case 0', () => {
var list = List("ABCD".split(''));
expect(moveInList(list, 0, 0).join('')).to.equal('ABCD');
});
示例8:
(data:Array<SearchResultRow>) => {
return Immutable.List<SearchResultRow>(data);
}
示例9: get
get(phrase:string):Immutable.List<SearchResultRow> {
if (this.phrases.has(phrase)) {
return this.phrases.get(phrase);
}
return Immutable.List<SearchResultRow>();
}
示例10: constructor
constructor(title:string = "", tasks:Immutable.List<Task> = Immutable.List<Task>([])) {
super({title: title, tasks: tasks});
}