{"size": 1348, "ext": "js", "max_stars_repo_path": "dist/atom/Atom.js", "max_stars_repo_name": "phovea/phovea_core", "max_stars_repo_stars_event_min_datetime": "2017-02-10T04:39:11.000Z", "max_stars_repo_stars_event_max_datetime": "2019-07-01T18:41:09.000Z", "max_issues_repo_path": "dist/atom/Atom.js", "max_issues_repo_name": "phovea/phovea_core", "max_issues_repo_issues_event_min_datetime": "2016-11-05T18:56:47.000Z", "max_issues_repo_issues_event_max_datetime": "2021-02-04T09:10:33.000Z", "max_forks_repo_path": "dist/atom/Atom.js", "max_forks_repo_name": "phovea/phovea_core", "max_forks_repo_forks_event_min_datetime": "2016-11-03T15:36:21.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-13T09:53:02.000Z"}
{"max_stars_count": 4, "max_issues_count": 123, "max_forks_count": 14, "avg_line_length": 28.0833333333, "max_line_length": 76, "alphanum_fraction": 0.5764094955}
/**
 * Created by Samuel Gratzl on 14.02.2017.
 */
import { BaseUtils } from '../base/BaseUtils';
import { ValueTypeUtils } from '../data/valuetype';
import { AtomUtils } from './IAtom';
import { LocalIDAssigner } from '../idtype';
import { AAtom } from './AAtom';
import { Range } from '../range';
const noValue = {
    id: -1,
    name: '',
    value: null
};
export class Atom extends AAtom {
    constructor(desc, loaded) {
        super(desc);
        this.loaded = loaded;
    }
    id() {
        return Promise.resolve(Range.list(this.loaded.id));
    }
    name() {
        return Promise.resolve(this.loaded.name);
    }
    data() {
        return Promise.resolve(this.loaded.value);
    }
    static create(desc) {
        if (typeof (desc.data) !== undefined) {
            return new Atom(desc, desc.data);
        }
        return new Atom(desc, noValue);
    }
    static asAtom(name, value, options = {}) {
        const desc = BaseUtils.mixin(AtomUtils.createDefaultAtomDesc(), {
            value: ValueTypeUtils.guessValueTypeDesc([value])
        }, options);
        const rowAssigner = options.rowassigner || LocalIDAssigner.create();
        const atom = {
            name,
            value,
            id: rowAssigner([name]).first
        };
        return new Atom(desc, atom);
    }
}
//# sourceMappingURL=Atom.js.map