Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function dataExprFn() {
oldVal = curVal
curVal = exprType === 'string' ? getByPath(context, expr) : expr.call(context)
if (handler.deep) {
curVal = toJS(curVal, false)
} else if (isObservableArray(curVal)) {
// 强制访问,让数组被观察
curVal.peek()
}
return curVal
}
self[property] = value
}
}
if (typeof val !== 'undefined') {
logger.debug('before load `' + property + '`:', self[property])
if (val == null) {
setVal()
}
else if (typeof self[property] === 'object' && self[property] !== null) {
if (typeof val === 'object') {
// remove overflow items if arrays
if (
Array.isArray(val) &&
(
isObservableArray(self[property]) || Array.isArray(self[property])
)
&& val.length < self[property].length
) {
self[property].splice(val.length, self[property].length - val.length)
}
if (Array.isArray(val)) {
val.forEach((v, k) => assignState(self[property], k, v))
}
else {
for (let k in val) {
if (val.hasOwnProperty(k)) {
assignState(self[property], k, val[k])
}
}
}
}
export function chunkProcessor(
observableArray: T[],
processor: (item: T[]) => void,
debounce = 0,
maxChunkSize = 0
): IDisposer {
if (!isObservableArray(observableArray))
throw new Error("Expected observable array as first argument")
if (!isAction(processor)) processor = action("chunkProcessor", processor)
const runner = () => {
while (observableArray.length > 0) {
let chunkSize =
maxChunkSize === 0
? observableArray.length
: Math.min(observableArray.length, maxChunkSize)
// construct a final set
const items = observableArray.slice(0, chunkSize)
// clear the slice for next iteration
runInAction(() => observableArray.splice(0, chunkSize))
// fire processor
processor(items)
}
}
if (detectCycles && __alreadySeen === null) {
__alreadySeen = []
}
if (detectCycles && source !== null && typeof source === "object") {
for (let i = 0, l = __alreadySeen.length; i < l; i++) {
if (__alreadySeen[i][0] === source) {
return __alreadySeen[i][1];
}
}
}
if (isObservable(source)) {
if (isObservableArray(source)) {
var res = cache([]);
var toAdd = source.map(function (value) { return toJS(value, detectCycles, __alreadySeen); });
res.length = toAdd.length;
for (var i = 0, l = toAdd.length; i < l; i++)
res[i] = toAdd[i];
return res;
}
if (isObservableObject(source)) {
var res = cache({});
for (var key in source)
res[key] = toJS(source[key], detectCycles, __alreadySeen);
return res;
}
if (isObservableMap(source)) {
var res_1 = cache({});
source.forEach(function (value, key) { return (res_1[key] = toJS(value, detectCycles, __alreadySeen)); });
Object.keys(target).forEach(key => {
if (typeof target[key] === 'object') {
if (isObservableMap(target[key])) return target[key].merge(source[key])
if (isObservableArray(target[key])) return target[key].replace(source[key])
extendObservable(target[key], source[key])
} else {
target[key] = source[key]
}
})
window.__STATE = target
global.size = function size(input) {
if (isObservableArray(input) || typeof input === 'string') {
return input.length
}
return input && ((typeof input === 'string') ? input.length : Object.keys(input).length)
}
function _isArray(o) {
return o instanceof Array || typeof o === 'array' || isObservableArray(o);
}
return arr.map(value => {
if(isPlainObject(value) || isObservableObject(value)){
return nestedMapFromObj(value);
}else if(isArray(value) || isObservableArray(value)){
return nestedMapFromArray(value);
}else if(isObject(value) && !isPlainObject(value)){
return observable.ref(value);
}else{
return value;
}
});
}
downloadCrowdsaleInfo = () => {
const zip = new JSZip()
const { files } = FILE_CONTENTS
const [NULL_FINALIZE_AGENT, FINALIZE_AGENT] = ['nullFinalizeAgent', 'finalizeAgent']
const tiersCount = isObservableArray(this.props.tierStore.tiers) ? this.props.tierStore.tiers.length : 1
const contractsKeys = tiersCount === 1 ? files.order.filter(c => c !== NULL_FINALIZE_AGENT) : files.order;
const orderNumber = order => order.toString().padStart(3, '0');
let prefix = 1
contractsKeys.forEach(key => {
if (this.props.contractStore.hasOwnProperty(key)) {
const { txt, sol, name } = files[key]
const { abiConstructor } = this.props.contractStore[key]
let tiersCountPerContract = isObservableArray(abiConstructor) ? abiConstructor.length : 1
if (tiersCount > 1 && [NULL_FINALIZE_AGENT, FINALIZE_AGENT].includes(key)) {
tiersCountPerContract = NULL_FINALIZE_AGENT === key ? tiersCount - 1 : 1
}
for (let tier = 0; tier < tiersCountPerContract; tier++) {
const suffix = tiersCountPerContract > 1 ? `_${tier + 1}` : ''
function transformRequestData(data: Object | Array) {
if (Array.isArray(data) || isObservableArray(data)) {
return transformRequestArray(data);
}
return transformRequestObject(data);
}