enum.resolve
0.000000

Resolves an enumerable.

Arguments
no defined arguments
Return Value
true

Enumerators are evaluated lazily, meaning they don't iterate over the underlying enumerable values until consumed. The enum.resolve proc forces the enumerator to resolve immediately, returning true on success.

something went wrong :(
Deleting all keys in a bucket
Setup
authorization=PROCAUTH
require "proc"

client = Proc.connect("PROCAUTH")
const Proc = require("@proc.dev/client");
const client = Proc.connect("PROCAUTH");
client.enum.resolve.call(
  client.keyv.scan(bucket: "t22f4883") >> client.enum.each {
    client.keyv.delete(bucket: "t22f4883")
  }
)
client.enum.resolve.call(
  client.keyv.scan(
    undefined, t22f4883
  ).compose(
    client.enum.each(undefined, {}, () => {
      return client.keyv.delete(
        undefined, t22f4883
      );
    })
  )
);
curl "https://proc.run/enum/resolve" --silent \
--header "authorization: bearer $authorization" \
--header "content-type: application/vnd.proc+json" \
--header "accept: text/plain" \
--data '[[">>", ["t22f4883"]]]]]]]]]'
 

true

Without the call to enum.resolve in the above example, the return value from enum.each would be returned to the client. Both approaches still have the same side-effects of deleting all keys in the bucket.

Enumerators are a complex topic but bring a lot of power to your projects—learn more in the docs.


Stuck? Want to chat about an idea? Join the community on Discord.