2019-05-16 00:58:44 +02:00
|
|
|
use crate::object::Value;
|
2019-05-13 23:00:25 +02:00
|
|
|
use crate::prelude::*;
|
|
|
|
|
2019-05-23 09:23:06 +02:00
|
|
|
pub fn to_array(args: CommandArgs) -> Result<OutputStream, ShellError> {
|
|
|
|
let out = args.input.collect();
|
|
|
|
Ok(out
|
|
|
|
.map(|vec: Vec<_>| single_output(Value::List(vec)))
|
|
|
|
.flatten_stream()
|
|
|
|
.boxed())
|
2019-05-13 23:00:25 +02:00
|
|
|
}
|
2019-05-15 18:12:38 +02:00
|
|
|
|
2019-05-23 09:23:06 +02:00
|
|
|
crate async fn stream_to_array(stream: InputStream) -> InputStream {
|
|
|
|
let out = Value::List(stream.collect().await);
|
2019-05-15 18:12:38 +02:00
|
|
|
let mut stream = VecDeque::new();
|
|
|
|
stream.push_back(out);
|
2019-05-23 09:23:06 +02:00
|
|
|
stream.boxed() as InputStream
|
2019-05-15 18:12:38 +02:00
|
|
|
}
|