在节点中使用.pipe()

时间:2015-09-14 14:32:39

标签: javascript node.js asynchronous

我不清楚.pipe()函数在节点中做了什么?

我怎么能用它来重构下面这两个函数中的任何一个?

//  The type argument to BindingTarget is the type of the property. 
_selectedValueBindingTarget = new BindingTarget<Object>();

_selectedValueBindingTarget.ValueChanged += (s, e2) =>
{
    SelectedValue = e2.NewValue;
};

Binding binding = new Binding("SelectedItem." + SelectedValuePath);
binding.Mode = BindingMode.OneWay;
binding.Source = this;
BindingOperations.SetBinding(_selectedValueBindingTarget, 
    BindingTarget<Object>.ValueProperty, binding);

//来自答案的新代码:

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
With rs
    Set .ActiveConnection = conn
    .LockType = adLockOptimistic
    .CursorLocation = adUseServer
    .CursorType = adOpenForwardOnly
    .Open "SET NOCOUNT ON"
End With
rs.Open Cmd, , , , adCmdStoredProc

MsgBox ("Success! " & rs.RecordCount & " Records Returned!")

1 个答案:

答案 0 :(得分:5)

.pipe将流的可读面与另一个流的可写面连接起来:

readable.pipe(writable)

即。它是一种将数据从一个流传递到另一个流的方法。它的节点等同于IUnix管道:

foo | bar
  

我怎么能用它来重构下面这两个函数中的任何一个?

由于您似乎无法连接两个流,因此无需使用.pipe