lib/dom/layer.js
function createLayer(document, parent, rawLayer) {
        if (!parent && !rawLayer.hasOwnProperty("type")) {
            return new LayerGroup(document, null, rawLayer);
        }

        switch (rawLayer.type) {
        case "layerSection":
        case "artboardSection":
        case "framedGroupSection":
            return new LayerGroup(document, parent, rawLayer);
        case "layer":
            return new Layer(document, parent, rawLayer);
        case "shapeLayer":
            return new ShapeLayer(document, parent, rawLayer);
        case "textLayer":
            return new TextLayer(document, parent, rawLayer);
        case "adjustmentLayer":
            return new AdjustmentLayer(document, parent, rawLayer);
        case "smartObjectLayer":
            return new SmartObjectLayer(document, parent, rawLayer);
        case "backgroundLayer":
            return new BackgroundLayer(document, parent, rawLayer);
        default:
            throw new Error("Unknown layer type:", rawLayer.type);
    }
    }
function createLayer(document, parent, rawLayer) {
        if (!parent && !rawLayer.hasOwnProperty("type")) {
            return new LayerGroup(document, null, rawLayer);
        }

        switch (rawLayer.type) {
        case "layerSection":
        case "artboardSection":
        case "framedGroupSection":
            return new LayerGroup(document, parent, rawLayer);
        case "layer":
            return new Layer(document, parent, rawLayer);
        case "shapeLayer":
            return new ShapeLayer(document, parent, rawLayer);
        case "textLayer":
            return new TextLayer(document, parent, rawLayer);
        case "adjustmentLayer":
            return new AdjustmentLayer(document, parent, rawLayer);
        case "smartObjectLayer":
            return new SmartObjectLayer(document, parent, rawLayer);
        case "backgroundLayer":
            return new BackgroundLayer(document, parent, rawLayer);
        default:
            throw new Error("Unknown layer type:", rawLayer.type);
    }
    }
function createLayer ( document , parent , rawLayer ) { if ( ! parent && ! rawLayer . hasOwnProperty ( "type" ) ) { return new LayerGroup ( document , null , rawLayer ) ; } switch ( rawLayer . type ) { case "layerSection" : case "artboardSection" : case "framedGroupSection" : return new LayerGroup ( document , parent , rawLayer ) ; case "layer" : return new Layer ( document , parent , rawLayer ) ; case "shapeLayer" : return new ShapeLayer ( document , parent , rawLayer ) ; case "textLayer" : return new TextLayer ( document , parent , rawLayer ) ; case "adjustmentLayer" : return new AdjustmentLayer ( document , parent , rawLayer ) ; case "smartObjectLayer" : return new SmartObjectLayer ( document , parent , rawLayer ) ; case "backgroundLayer" : return new BackgroundLayer ( document , parent , rawLayer ) ; default : throw new Error ( "Unknown layer type:" , rawLayer . type ) ; } }
Create a new layer object of the appropriate type for the given raw
description. The new layer is not attached to its parent layer.

@param {Document} document The parent document for the new layer
@param {?BaseLayer} parent The parent layer for the new layer
@param {object} rawLayer The raw description of the new layer
@return {BaseLayer} A subtype of the abstract BaseLayer class.
Create a new layer object of the appropriate type for the given raw description . The new layer is not attached to its parent layer .