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