本文整理汇总了TypeScript中Immutable.Map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Map函数的具体用法?TypeScript Map怎么用?TypeScript Map使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Map函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
import { NotebookContentRecord, NotebookModel } from "./notebook";
import { DirectoryContentRecord, DirectoryModelRecord } from "./directory";
import { DummyContentRecord, EmptyModelRecord } from "./dummy";
import { FileContentRecord, FileModelRecord } from "./file";
export * from "./notebook";
export * from "./directory";
export * from "./dummy";
export * from "./file";
export type ContentModel =
| NotebookModel
| DirectoryModelRecord
| FileModelRecord
| EmptyModelRecord;
export type ContentRecord =
| NotebookContentRecord
| DummyContentRecord
| FileContentRecord
| DirectoryContentRecord;
export type ContentsRecordProps = {
byRef: Immutable.Map<ContentRef, ContentRecord>;
};
export const makeContentsRecord = Immutable.Record<ContentsRecordProps>({
byRef: Immutable.Map()
});
示例2: publishName
public publishName() {
publish({
key: Keys.ChangeName,
payload: Map({name:this.name()})
})
}
示例4:
export const transientCellMap = (model: NotebookModel) =>
model.transient.get("cellMap", Immutable.Map());
示例5: it
it('merges two maps with a merge function', () => {
var m1 = Map({a:1,b:2,c:3});
var m2 = Map({d:10,b:20,e:30});
expect(m1.mergeWith((a, b) => a + b, m2)).is(Map({a:1,b:22,c:3,d:10,e:30}));
})
示例6:
combineReducers<State, AnyAction, string>({}, () => { return Map<string, State>(); });
示例7: it
it('is conservative with array-likes, only accepting true Arrays.', () => {
expect(fromJS({1: 2, length: 3})).is(
Map().set('1', 2).set('length', 3)
);
expect(fromJS('string')).toEqual('string');
});
示例8: describe
describe('Conversion', () => {
beforeEach(function () {
this.addMatchers({
is: function(expected) {
return is(this.actual, expected);
}
});
});
// Note: order of keys based on Map's hashing order
var js = {
deepList: [
{
position: "first"
},
{
position: "second"
},
{
position: "third"
},
],
deepMap: {
a: "A",
b: "B"
},
emptyMap: Object.create(null),
point: {x: 10, y: 20},
string: "Hello",
list: [1, 2, 3]
};
var Point = Record({x:0, y:0}, 'Point');
var immutableData = Map({
deepList: List.of(
Map({
position: "first"
}),
Map({
position: "second"
}),
Map({
position: "third"
})
),
deepMap: Map({
a: "A",
b: "B"
}),
emptyMap: Map(),
point: Map({x: 10, y: 20}),
string: "Hello",
list: List.of(1, 2, 3)
});
var immutableOrderedData = OrderedMap({
deepList: List.of(
OrderedMap({
position: "first"
}),
OrderedMap({
position: "second"
}),
OrderedMap({
position: "third"
})
),
deepMap: OrderedMap({
a: "A",
b: "B"
}),
emptyMap: OrderedMap(),
point: new Point({x: 10, y: 20}),
string: "Hello",
list: List.of(1, 2, 3)
});
var immutableOrderedDataString = 'OrderedMap { ' +
'"deepList": List [ '+
'OrderedMap { '+
'"position": "first"'+
' }, ' +
'OrderedMap { '+
'"position": "second"'+
' }, '+
'OrderedMap { '+
'"position": "third"'+
' }' +
' ], '+
'"deepMap": OrderedMap { '+
'"a": "A", '+
'"b": "B"'+
' }, '+
'"emptyMap": OrderedMap {}, ' +
'"point": Point { "x": 10, "y": 20 }, '+
'"string": "Hello", '+
'"list": List [ 1, 2, 3 ]'+
' }';
//.........这里部分代码省略.........
示例9: it
it ('returns a default state', () => {
let reduc = reducer(undefined, {})
verifyDefault(reduc);
expect( Immutable.is(reduc.result, Immutable.Map()) ).toBeTruthy();
});