我收到大陣對:[number, {number,number, big array of numbers}]
在ramda.js中,fromPairs是否改變了元素的順序?
首先我我主要對添加到數組的開頭:
prepend([target[0], {count : target[1].length, overall : target[1].length, items:target[1]}]),
接下來我做的:
Promise.all([
to_file_json(
token.user_id,
'connections_data',
JSON.stringify(
fromPairs(r[0])
))...
而且我能找到我的主在我的文件中間的某個地方配對。
所以我的問題是,fromPairs
可能會改變順序?如果是,我能做些什麼來防止這種情況發生?
編輯:
附加信息:
1)r
變量對應於[[number, Friends][], Float64Array[]]
2)target
變量對應於[number,number[]]
3)元件的初期其中我是前置,它總是最大的一個,它以某種方式處於文件的中間。
"136444868":{"count":304,"overall":304,"items":[19363,234566,290677,1375661,2030175,2131497,2593602,2596894,2816890,2869895,3170377,3437884,3486703,3504543,4046799,4235623,5366101.....
4)友類型:
interface Friends {
count:number,
overall:number,
items:number[]
};
樣本數據
{
"19363":{"count":5,"overall":3088,"items":[51177198,53119509,136035431,209482119,216378147]}
,"234566":{"count":6,"overall":6803,"items":[290677,3504543,23180680,75311610,178479726,196401211]}
,"290677":{"count":19,"overall":2213,"items":[234566,5686439,7873089,11175816,13726459,20697213,23180680,27419631,55209039,74493674,75311610,125041200,133272552,139307068,159591583,168386810,173599247,178429642,189097165]}
,"1375661":{"count":0,"overall":76,"items":[]},"2030175":{"count":14,"overall":86,"items":[2596894,6507568,11681736,17736119,49557638,117771194,127144880,141523415,147264238,153044182,156925389,160656334,223530741,262311445]},"2131497":{"count":16,"overall":301,"items":[13598979,15682478,20357560,20869716,27419631,30869837,33650605,40129023,68976427,88146695,90648231,101105191,118193129,145163503,216503667,387266562]},
你能展示一些演示這個問題的示例數據嗎? –
好的一刻 –
請注意,拉姆達認爲對象是無序集合。但是,假設底層引擎不重新排序,該對象可能會有按照它們添加的順序迭代的鍵。這意味着'fromPairs'和'toPairs'應該像反向一樣。不過,拉姆達本身並不強制執行此操作。 –