This repository has been archived by the owner on Jan 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use named exports and update props in docs
- Loading branch information
1 parent
313ce74
commit 2150854
Showing
4 changed files
with
128 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import { PluginObject } from "vue"; | ||
import { VueTransmit } from "./src/index"; | ||
import { XHRUploadAdapter } from "./src/upload-adapters/xhr"; | ||
|
||
const Plugin: PluginObject<undefined> = { | ||
const VueTransitPlugin: PluginObject<undefined> = { | ||
install(Vue) { | ||
Vue.component("VueTransmit", VueTransmit); | ||
}, | ||
name: "vue-transmit", | ||
}; | ||
|
||
export default Plugin; | ||
export { VueTransitPlugin, VueTransmit, XHRUploadAdapter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const { VueTransmit, XHRUploadAdapter } = require("../dist/vue-transmit"); | ||
const { format } = require("util"); | ||
|
||
let { props } = VueTransmit.options; | ||
let data = Object.keys(props) | ||
.map(k => new_comp_desc(k, props[k])) | ||
.map(d => `|${d.Property}|${d.Type}|${(d.Default || "").toString()}|`) | ||
.join("\n"); | ||
|
||
console.log(data); | ||
|
||
props = new XHRUploadAdapter({}, { url: "" }); | ||
data = Object.keys(props) | ||
.map(k => new_class_desc(k, props)) | ||
.map(d => `|${d.Property}|${d.Type}|${(d.Default || "").toString()}|`) | ||
.join("\n"); | ||
|
||
console.log(data); | ||
|
||
function new_comp_desc(prop, descriptor) { | ||
let desc = Object.create(null); | ||
|
||
desc.Property = prop; | ||
desc.Type = resolve_type(descriptor.type); | ||
desc.Default = fmt(descriptor.default); | ||
if (descriptor.required) { | ||
desc.Required = "✓"; | ||
} | ||
|
||
return desc; | ||
} | ||
|
||
function new_class_desc(prop, instance) { | ||
let desc = Object.create(null); | ||
|
||
desc.Property = prop; | ||
desc.Type = typeof instance[prop]; | ||
desc.Default = fmt(instance[prop]); | ||
|
||
return desc; | ||
} | ||
|
||
function resolve_type(t) { | ||
if (Array.isArray(t)) { | ||
return t.map(resolve_type).join(", "); | ||
} | ||
|
||
if (typeof t !== "function") { | ||
throw new TypeError(); | ||
} | ||
|
||
return t.name; | ||
} | ||
|
||
function fmt(x) { | ||
if (x === null) { | ||
return "null"; | ||
} | ||
switch (typeof x) { | ||
case "number": | ||
return format("%d", x); | ||
case "object": | ||
case "symbol": | ||
case "function": | ||
return format("%O", x); | ||
case "string": | ||
case "boolean": | ||
case "undefined": | ||
default: | ||
return format("%s", x); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters